cu2qu.c 636 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860
  1. /* Generated by Cython 3.2.4 */
  2. /* BEGIN: Cython Metadata
  3. {
  4. "distutils": {
  5. "define_macros": [
  6. [
  7. "CYTHON_TRACE_NOGIL",
  8. "1"
  9. ]
  10. ],
  11. "name": "fontTools.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_4"
  41. #define CYTHON_HEX_VERSION 0x030204F0
  42. #define CYTHON_FUTURE_DIVISION 1
  43. /* CModulePreamble */
  44. #include <stddef.h>
  45. #ifndef offsetof
  46. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  47. #endif
  48. #if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS)
  49. #ifndef __stdcall
  50. #define __stdcall
  51. #endif
  52. #ifndef __cdecl
  53. #define __cdecl
  54. #endif
  55. #ifndef __fastcall
  56. #define __fastcall
  57. #endif
  58. #endif
  59. #ifndef DL_IMPORT
  60. #define DL_IMPORT(t) t
  61. #endif
  62. #ifndef DL_EXPORT
  63. #define DL_EXPORT(t) t
  64. #endif
  65. #define __PYX_COMMA ,
  66. #ifndef PY_LONG_LONG
  67. #define PY_LONG_LONG LONG_LONG
  68. #endif
  69. #ifndef Py_HUGE_VAL
  70. #define Py_HUGE_VAL HUGE_VAL
  71. #endif
  72. #define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX
  73. #if defined(GRAALVM_PYTHON)
  74. /* For very preliminary testing purposes. Most variables are set the same as PyPy.
  75. The existence of this section does not imply that anything works or is even tested */
  76. #define CYTHON_COMPILING_IN_PYPY 0
  77. #define CYTHON_COMPILING_IN_CPYTHON 0
  78. #define CYTHON_COMPILING_IN_LIMITED_API 0
  79. #define CYTHON_COMPILING_IN_GRAAL 1
  80. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  81. #undef CYTHON_USE_TYPE_SLOTS
  82. #define CYTHON_USE_TYPE_SLOTS 0
  83. #undef CYTHON_USE_TYPE_SPECS
  84. #define CYTHON_USE_TYPE_SPECS 0
  85. #undef CYTHON_USE_PYTYPE_LOOKUP
  86. #define CYTHON_USE_PYTYPE_LOOKUP 0
  87. #undef CYTHON_USE_PYLIST_INTERNALS
  88. #define CYTHON_USE_PYLIST_INTERNALS 0
  89. #undef CYTHON_USE_UNICODE_INTERNALS
  90. #define CYTHON_USE_UNICODE_INTERNALS 0
  91. #undef CYTHON_USE_UNICODE_WRITER
  92. #define CYTHON_USE_UNICODE_WRITER 0
  93. #undef CYTHON_USE_PYLONG_INTERNALS
  94. #define CYTHON_USE_PYLONG_INTERNALS 0
  95. #undef CYTHON_AVOID_BORROWED_REFS
  96. #define CYTHON_AVOID_BORROWED_REFS 1
  97. #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  98. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
  99. #undef CYTHON_ASSUME_SAFE_MACROS
  100. #define CYTHON_ASSUME_SAFE_MACROS 0
  101. #undef CYTHON_ASSUME_SAFE_SIZE
  102. #define CYTHON_ASSUME_SAFE_SIZE 0
  103. #undef CYTHON_UNPACK_METHODS
  104. #define CYTHON_UNPACK_METHODS 0
  105. #undef CYTHON_FAST_THREAD_STATE
  106. #define CYTHON_FAST_THREAD_STATE 0
  107. #undef CYTHON_FAST_GIL
  108. #define CYTHON_FAST_GIL 0
  109. #undef CYTHON_METH_FASTCALL
  110. #define CYTHON_METH_FASTCALL 0
  111. #undef CYTHON_FAST_PYCALL
  112. #define CYTHON_FAST_PYCALL 0
  113. #ifndef CYTHON_PEP487_INIT_SUBCLASS
  114. #define CYTHON_PEP487_INIT_SUBCLASS 1
  115. #endif
  116. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  117. #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  118. #undef CYTHON_USE_MODULE_STATE
  119. #define CYTHON_USE_MODULE_STATE 0
  120. #undef CYTHON_USE_SYS_MONITORING
  121. #define CYTHON_USE_SYS_MONITORING 0
  122. #undef CYTHON_USE_TP_FINALIZE
  123. #define CYTHON_USE_TP_FINALIZE 0
  124. #undef CYTHON_USE_AM_SEND
  125. #define CYTHON_USE_AM_SEND 0
  126. #undef CYTHON_USE_DICT_VERSIONS
  127. #define CYTHON_USE_DICT_VERSIONS 0
  128. #undef CYTHON_USE_EXC_INFO_STACK
  129. #define CYTHON_USE_EXC_INFO_STACK 1
  130. #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
  131. #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
  132. #endif
  133. #undef CYTHON_USE_FREELISTS
  134. #define CYTHON_USE_FREELISTS 0
  135. #undef CYTHON_IMMORTAL_CONSTANTS
  136. #define CYTHON_IMMORTAL_CONSTANTS 0
  137. #elif defined(PYPY_VERSION)
  138. #define CYTHON_COMPILING_IN_PYPY 1
  139. #define CYTHON_COMPILING_IN_CPYTHON 0
  140. #define CYTHON_COMPILING_IN_LIMITED_API 0
  141. #define CYTHON_COMPILING_IN_GRAAL 0
  142. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  143. #undef CYTHON_USE_TYPE_SLOTS
  144. #define CYTHON_USE_TYPE_SLOTS 1
  145. #ifndef CYTHON_USE_TYPE_SPECS
  146. #define CYTHON_USE_TYPE_SPECS 0
  147. #endif
  148. #undef CYTHON_USE_PYTYPE_LOOKUP
  149. #define CYTHON_USE_PYTYPE_LOOKUP 0
  150. #undef CYTHON_USE_PYLIST_INTERNALS
  151. #define CYTHON_USE_PYLIST_INTERNALS 0
  152. #undef CYTHON_USE_UNICODE_INTERNALS
  153. #define CYTHON_USE_UNICODE_INTERNALS 0
  154. #undef CYTHON_USE_UNICODE_WRITER
  155. #define CYTHON_USE_UNICODE_WRITER 0
  156. #undef CYTHON_USE_PYLONG_INTERNALS
  157. #define CYTHON_USE_PYLONG_INTERNALS 0
  158. #undef CYTHON_AVOID_BORROWED_REFS
  159. #define CYTHON_AVOID_BORROWED_REFS 1
  160. #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  161. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1
  162. #undef CYTHON_ASSUME_SAFE_MACROS
  163. #define CYTHON_ASSUME_SAFE_MACROS 0
  164. #ifndef CYTHON_ASSUME_SAFE_SIZE
  165. #define CYTHON_ASSUME_SAFE_SIZE 1
  166. #endif
  167. #undef CYTHON_UNPACK_METHODS
  168. #define CYTHON_UNPACK_METHODS 0
  169. #undef CYTHON_FAST_THREAD_STATE
  170. #define CYTHON_FAST_THREAD_STATE 0
  171. #undef CYTHON_FAST_GIL
  172. #define CYTHON_FAST_GIL 0
  173. #undef CYTHON_METH_FASTCALL
  174. #define CYTHON_METH_FASTCALL 0
  175. #undef CYTHON_FAST_PYCALL
  176. #define CYTHON_FAST_PYCALL 0
  177. #ifndef CYTHON_PEP487_INIT_SUBCLASS
  178. #define CYTHON_PEP487_INIT_SUBCLASS 1
  179. #endif
  180. #if PY_VERSION_HEX < 0x03090000
  181. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  182. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  183. #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT)
  184. #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  185. #endif
  186. #undef CYTHON_USE_MODULE_STATE
  187. #define CYTHON_USE_MODULE_STATE 0
  188. #undef CYTHON_USE_SYS_MONITORING
  189. #define CYTHON_USE_SYS_MONITORING 0
  190. #ifndef CYTHON_USE_TP_FINALIZE
  191. #define CYTHON_USE_TP_FINALIZE (PYPY_VERSION_NUM >= 0x07030C00)
  192. #endif
  193. #undef CYTHON_USE_AM_SEND
  194. #define CYTHON_USE_AM_SEND 0
  195. #undef CYTHON_USE_DICT_VERSIONS
  196. #define CYTHON_USE_DICT_VERSIONS 0
  197. #undef CYTHON_USE_EXC_INFO_STACK
  198. #define CYTHON_USE_EXC_INFO_STACK 0
  199. #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
  200. #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_NUM >= 0x07031100)
  201. #endif
  202. #undef CYTHON_USE_FREELISTS
  203. #define CYTHON_USE_FREELISTS 0
  204. #undef CYTHON_IMMORTAL_CONSTANTS
  205. #define CYTHON_IMMORTAL_CONSTANTS 0
  206. #elif defined(CYTHON_LIMITED_API)
  207. #ifdef Py_LIMITED_API
  208. #undef __PYX_LIMITED_VERSION_HEX
  209. #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API
  210. #endif
  211. #define CYTHON_COMPILING_IN_PYPY 0
  212. #define CYTHON_COMPILING_IN_CPYTHON 0
  213. #define CYTHON_COMPILING_IN_LIMITED_API 1
  214. #define CYTHON_COMPILING_IN_GRAAL 0
  215. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  216. #undef CYTHON_USE_TYPE_SLOTS
  217. #define CYTHON_USE_TYPE_SLOTS 0
  218. #undef CYTHON_USE_TYPE_SPECS
  219. #define CYTHON_USE_TYPE_SPECS 1
  220. #undef CYTHON_USE_PYTYPE_LOOKUP
  221. #define CYTHON_USE_PYTYPE_LOOKUP 0
  222. #undef CYTHON_USE_PYLIST_INTERNALS
  223. #define CYTHON_USE_PYLIST_INTERNALS 0
  224. #undef CYTHON_USE_UNICODE_INTERNALS
  225. #define CYTHON_USE_UNICODE_INTERNALS 0
  226. #ifndef CYTHON_USE_UNICODE_WRITER
  227. #define CYTHON_USE_UNICODE_WRITER 0
  228. #endif
  229. #undef CYTHON_USE_PYLONG_INTERNALS
  230. #define CYTHON_USE_PYLONG_INTERNALS 0
  231. #ifndef CYTHON_AVOID_BORROWED_REFS
  232. #define CYTHON_AVOID_BORROWED_REFS 0
  233. #endif
  234. #ifndef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  235. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
  236. #endif
  237. #undef CYTHON_ASSUME_SAFE_MACROS
  238. #define CYTHON_ASSUME_SAFE_MACROS 0
  239. #undef CYTHON_ASSUME_SAFE_SIZE
  240. #define CYTHON_ASSUME_SAFE_SIZE 0
  241. #undef CYTHON_UNPACK_METHODS
  242. #define CYTHON_UNPACK_METHODS 0
  243. #undef CYTHON_FAST_THREAD_STATE
  244. #define CYTHON_FAST_THREAD_STATE 0
  245. #undef CYTHON_FAST_GIL
  246. #define CYTHON_FAST_GIL 0
  247. #undef CYTHON_METH_FASTCALL
  248. #define CYTHON_METH_FASTCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000)
  249. #undef CYTHON_FAST_PYCALL
  250. #define CYTHON_FAST_PYCALL 0
  251. #ifndef CYTHON_PEP487_INIT_SUBCLASS
  252. #define CYTHON_PEP487_INIT_SUBCLASS 1
  253. #endif
  254. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  255. #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  256. #endif
  257. #ifndef CYTHON_USE_MODULE_STATE
  258. #define CYTHON_USE_MODULE_STATE 0
  259. #endif
  260. #undef CYTHON_USE_SYS_MONITORING
  261. #define CYTHON_USE_SYS_MONITORING 0
  262. #ifndef CYTHON_USE_TP_FINALIZE
  263. #define CYTHON_USE_TP_FINALIZE 0
  264. #endif
  265. #ifndef CYTHON_USE_AM_SEND
  266. #define CYTHON_USE_AM_SEND (__PYX_LIMITED_VERSION_HEX >= 0x030A0000)
  267. #endif
  268. #undef CYTHON_USE_DICT_VERSIONS
  269. #define CYTHON_USE_DICT_VERSIONS 0
  270. #undef CYTHON_USE_EXC_INFO_STACK
  271. #define CYTHON_USE_EXC_INFO_STACK 0
  272. #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
  273. #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
  274. #endif
  275. #ifndef CYTHON_USE_FREELISTS
  276. #define CYTHON_USE_FREELISTS 1
  277. #endif
  278. #undef CYTHON_IMMORTAL_CONSTANTS
  279. #define CYTHON_IMMORTAL_CONSTANTS 0
  280. #else
  281. #define CYTHON_COMPILING_IN_PYPY 0
  282. #define CYTHON_COMPILING_IN_CPYTHON 1
  283. #define CYTHON_COMPILING_IN_LIMITED_API 0
  284. #define CYTHON_COMPILING_IN_GRAAL 0
  285. #ifdef Py_GIL_DISABLED
  286. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 1
  287. #else
  288. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  289. #endif
  290. #if PY_VERSION_HEX < 0x030A0000
  291. #undef CYTHON_USE_TYPE_SLOTS
  292. #define CYTHON_USE_TYPE_SLOTS 1
  293. #elif !defined(CYTHON_USE_TYPE_SLOTS)
  294. #define CYTHON_USE_TYPE_SLOTS 1
  295. #endif
  296. #ifndef CYTHON_USE_TYPE_SPECS
  297. #define CYTHON_USE_TYPE_SPECS 0
  298. #endif
  299. #ifndef CYTHON_USE_PYTYPE_LOOKUP
  300. #define CYTHON_USE_PYTYPE_LOOKUP 1
  301. #endif
  302. #ifndef CYTHON_USE_PYLONG_INTERNALS
  303. #define CYTHON_USE_PYLONG_INTERNALS 1
  304. #endif
  305. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  306. #undef CYTHON_USE_PYLIST_INTERNALS
  307. #define CYTHON_USE_PYLIST_INTERNALS 0
  308. #elif !defined(CYTHON_USE_PYLIST_INTERNALS)
  309. #define CYTHON_USE_PYLIST_INTERNALS 1
  310. #endif
  311. #ifndef CYTHON_USE_UNICODE_INTERNALS
  312. #define CYTHON_USE_UNICODE_INTERNALS 1
  313. #endif
  314. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING || PY_VERSION_HEX >= 0x030B00A2
  315. #undef CYTHON_USE_UNICODE_WRITER
  316. #define CYTHON_USE_UNICODE_WRITER 0
  317. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  318. #define CYTHON_USE_UNICODE_WRITER 1
  319. #endif
  320. #ifndef CYTHON_AVOID_BORROWED_REFS
  321. #define CYTHON_AVOID_BORROWED_REFS 0
  322. #endif
  323. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  324. #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  325. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1
  326. #elif !defined(CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)
  327. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
  328. #endif
  329. #ifndef CYTHON_ASSUME_SAFE_MACROS
  330. #define CYTHON_ASSUME_SAFE_MACROS 1
  331. #endif
  332. #ifndef CYTHON_ASSUME_SAFE_SIZE
  333. #define CYTHON_ASSUME_SAFE_SIZE 1
  334. #endif
  335. #ifndef CYTHON_UNPACK_METHODS
  336. #define CYTHON_UNPACK_METHODS 1
  337. #endif
  338. #ifndef CYTHON_FAST_THREAD_STATE
  339. #define CYTHON_FAST_THREAD_STATE 1
  340. #endif
  341. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  342. #undef CYTHON_FAST_GIL
  343. #define CYTHON_FAST_GIL 0
  344. #elif !defined(CYTHON_FAST_GIL)
  345. #define CYTHON_FAST_GIL (PY_VERSION_HEX < 0x030C00A6)
  346. #endif
  347. #ifndef CYTHON_METH_FASTCALL
  348. #define CYTHON_METH_FASTCALL 1
  349. #endif
  350. #ifndef CYTHON_FAST_PYCALL
  351. #define CYTHON_FAST_PYCALL 1
  352. #endif
  353. #ifndef CYTHON_PEP487_INIT_SUBCLASS
  354. #define CYTHON_PEP487_INIT_SUBCLASS 1
  355. #endif
  356. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  357. #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  358. #endif
  359. #ifndef CYTHON_USE_MODULE_STATE
  360. #define CYTHON_USE_MODULE_STATE 0
  361. #endif
  362. #ifndef CYTHON_USE_SYS_MONITORING
  363. #define CYTHON_USE_SYS_MONITORING (PY_VERSION_HEX >= 0x030d00B1)
  364. #endif
  365. #ifndef CYTHON_USE_TP_FINALIZE
  366. #define CYTHON_USE_TP_FINALIZE 1
  367. #endif
  368. #ifndef CYTHON_USE_AM_SEND
  369. #define CYTHON_USE_AM_SEND 1
  370. #endif
  371. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  372. #undef CYTHON_USE_DICT_VERSIONS
  373. #define CYTHON_USE_DICT_VERSIONS 0
  374. #elif !defined(CYTHON_USE_DICT_VERSIONS)
  375. #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5 && !CYTHON_USE_MODULE_STATE)
  376. #endif
  377. #ifndef CYTHON_USE_EXC_INFO_STACK
  378. #define CYTHON_USE_EXC_INFO_STACK 1
  379. #endif
  380. #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
  381. #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
  382. #endif
  383. #ifndef CYTHON_USE_FREELISTS
  384. #define CYTHON_USE_FREELISTS (!CYTHON_COMPILING_IN_CPYTHON_FREETHREADING)
  385. #endif
  386. #if defined(CYTHON_IMMORTAL_CONSTANTS) && PY_VERSION_HEX < 0x030C0000
  387. #undef CYTHON_IMMORTAL_CONSTANTS
  388. #define CYTHON_IMMORTAL_CONSTANTS 0 // definitely won't work
  389. #elif !defined(CYTHON_IMMORTAL_CONSTANTS)
  390. #define CYTHON_IMMORTAL_CONSTANTS (PY_VERSION_HEX >= 0x030C0000 && !CYTHON_USE_MODULE_STATE && CYTHON_COMPILING_IN_CPYTHON_FREETHREADING)
  391. #endif
  392. #endif
  393. #ifndef CYTHON_COMPRESS_STRINGS
  394. #define CYTHON_COMPRESS_STRINGS 1
  395. #endif
  396. #ifndef CYTHON_FAST_PYCCALL
  397. #define CYTHON_FAST_PYCCALL CYTHON_FAST_PYCALL
  398. #endif
  399. #ifndef CYTHON_VECTORCALL
  400. #if CYTHON_COMPILING_IN_LIMITED_API
  401. #define CYTHON_VECTORCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000)
  402. #else
  403. #define CYTHON_VECTORCALL (CYTHON_FAST_PYCCALL)
  404. #endif
  405. #endif
  406. #if CYTHON_USE_PYLONG_INTERNALS
  407. #undef SHIFT
  408. #undef BASE
  409. #undef MASK
  410. #ifdef SIZEOF_VOID_P
  411. enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  412. #endif
  413. #endif
  414. #ifndef __has_attribute
  415. #define __has_attribute(x) 0
  416. #endif
  417. #ifndef __has_cpp_attribute
  418. #define __has_cpp_attribute(x) 0
  419. #endif
  420. #ifndef CYTHON_RESTRICT
  421. #if defined(__GNUC__)
  422. #define CYTHON_RESTRICT __restrict__
  423. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  424. #define CYTHON_RESTRICT __restrict
  425. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  426. #define CYTHON_RESTRICT restrict
  427. #else
  428. #define CYTHON_RESTRICT
  429. #endif
  430. #endif
  431. #ifndef CYTHON_UNUSED
  432. #if defined(__cplusplus)
  433. /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17
  434. * but leads to warnings with -pedantic, since it is a C++17 feature */
  435. #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
  436. #if __has_cpp_attribute(maybe_unused)
  437. #define CYTHON_UNUSED [[maybe_unused]]
  438. #endif
  439. #endif
  440. #endif
  441. #endif
  442. #ifndef CYTHON_UNUSED
  443. # if defined(__GNUC__)
  444. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  445. # define CYTHON_UNUSED __attribute__ ((__unused__))
  446. # else
  447. # define CYTHON_UNUSED
  448. # endif
  449. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  450. # define CYTHON_UNUSED __attribute__ ((__unused__))
  451. # else
  452. # define CYTHON_UNUSED
  453. # endif
  454. #endif
  455. #ifndef CYTHON_UNUSED_VAR
  456. # if defined(__cplusplus)
  457. template<class T> void CYTHON_UNUSED_VAR( const T& ) { }
  458. # else
  459. # define CYTHON_UNUSED_VAR(x) (void)(x)
  460. # endif
  461. #endif
  462. #ifndef CYTHON_MAYBE_UNUSED_VAR
  463. #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x)
  464. #endif
  465. #ifndef CYTHON_NCP_UNUSED
  466. # if CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  467. # define CYTHON_NCP_UNUSED
  468. # else
  469. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  470. # endif
  471. #endif
  472. #ifndef CYTHON_USE_CPP_STD_MOVE
  473. #if defined(__cplusplus) && (\
  474. __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600))
  475. #define CYTHON_USE_CPP_STD_MOVE 1
  476. #else
  477. #define CYTHON_USE_CPP_STD_MOVE 0
  478. #endif
  479. #endif
  480. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  481. #include <stdint.h>
  482. typedef uintptr_t __pyx_uintptr_t;
  483. #ifndef CYTHON_FALLTHROUGH
  484. #if defined(__cplusplus)
  485. /* for clang __has_cpp_attribute(fallthrough) is true even before C++17
  486. * but leads to warnings with -pedantic, since it is a C++17 feature */
  487. #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
  488. #if __has_cpp_attribute(fallthrough)
  489. #define CYTHON_FALLTHROUGH [[fallthrough]]
  490. #endif
  491. #endif
  492. #ifndef CYTHON_FALLTHROUGH
  493. #if __has_cpp_attribute(clang::fallthrough)
  494. #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
  495. #elif __has_cpp_attribute(gnu::fallthrough)
  496. #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
  497. #endif
  498. #endif
  499. #endif
  500. #ifndef CYTHON_FALLTHROUGH
  501. #if __has_attribute(fallthrough)
  502. #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
  503. #else
  504. #define CYTHON_FALLTHROUGH
  505. #endif
  506. #endif
  507. #if defined(__clang__) && defined(__apple_build_version__)
  508. #if __apple_build_version__ < 7000000
  509. #undef CYTHON_FALLTHROUGH
  510. #define CYTHON_FALLTHROUGH
  511. #endif
  512. #endif
  513. #endif
  514. #ifndef Py_UNREACHABLE
  515. #define Py_UNREACHABLE() assert(0); abort()
  516. #endif
  517. #ifdef __cplusplus
  518. template <typename T>
  519. struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);};
  520. #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL<type>::value)
  521. #else
  522. #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0)
  523. #endif
  524. #if CYTHON_COMPILING_IN_PYPY == 1
  525. #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x030A0000)
  526. #else
  527. #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x03090000)
  528. #endif
  529. #define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer))
  530. /* CInitCode */
  531. #ifndef CYTHON_INLINE
  532. #if defined(__clang__)
  533. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  534. #elif defined(__GNUC__)
  535. #define CYTHON_INLINE __inline__
  536. #elif defined(_MSC_VER)
  537. #define CYTHON_INLINE __inline
  538. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  539. #define CYTHON_INLINE inline
  540. #else
  541. #define CYTHON_INLINE
  542. #endif
  543. #endif
  544. /* PythonCompatibility */
  545. #define __PYX_BUILD_PY_SSIZE_T "n"
  546. #define CYTHON_FORMAT_SSIZE_T "z"
  547. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  548. #define __Pyx_DefaultClassType PyType_Type
  549. #if CYTHON_COMPILING_IN_LIMITED_API
  550. #ifndef CO_OPTIMIZED
  551. static int CO_OPTIMIZED;
  552. #endif
  553. #ifndef CO_NEWLOCALS
  554. static int CO_NEWLOCALS;
  555. #endif
  556. #ifndef CO_VARARGS
  557. static int CO_VARARGS;
  558. #endif
  559. #ifndef CO_VARKEYWORDS
  560. static int CO_VARKEYWORDS;
  561. #endif
  562. #ifndef CO_ASYNC_GENERATOR
  563. static int CO_ASYNC_GENERATOR;
  564. #endif
  565. #ifndef CO_GENERATOR
  566. static int CO_GENERATOR;
  567. #endif
  568. #ifndef CO_COROUTINE
  569. static int CO_COROUTINE;
  570. #endif
  571. #else
  572. #ifndef CO_COROUTINE
  573. #define CO_COROUTINE 0x80
  574. #endif
  575. #ifndef CO_ASYNC_GENERATOR
  576. #define CO_ASYNC_GENERATOR 0x200
  577. #endif
  578. #endif
  579. static int __Pyx_init_co_variables(void);
  580. #if PY_VERSION_HEX >= 0x030900A4 || defined(Py_IS_TYPE)
  581. #define __Pyx_IS_TYPE(ob, type) Py_IS_TYPE(ob, type)
  582. #else
  583. #define __Pyx_IS_TYPE(ob, type) (((const PyObject*)ob)->ob_type == (type))
  584. #endif
  585. #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is)
  586. #define __Pyx_Py_Is(x, y) Py_Is(x, y)
  587. #else
  588. #define __Pyx_Py_Is(x, y) ((x) == (y))
  589. #endif
  590. #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone)
  591. #define __Pyx_Py_IsNone(ob) Py_IsNone(ob)
  592. #else
  593. #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None)
  594. #endif
  595. #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue)
  596. #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob)
  597. #else
  598. #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True)
  599. #endif
  600. #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse)
  601. #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob)
  602. #else
  603. #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False)
  604. #endif
  605. #define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj))
  606. #if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY
  607. #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o)
  608. #else
  609. #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o)
  610. #endif
  611. #ifndef Py_TPFLAGS_CHECKTYPES
  612. #define Py_TPFLAGS_CHECKTYPES 0
  613. #endif
  614. #ifndef Py_TPFLAGS_HAVE_INDEX
  615. #define Py_TPFLAGS_HAVE_INDEX 0
  616. #endif
  617. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  618. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  619. #endif
  620. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  621. #define Py_TPFLAGS_HAVE_FINALIZE 0
  622. #endif
  623. #ifndef Py_TPFLAGS_SEQUENCE
  624. #define Py_TPFLAGS_SEQUENCE 0
  625. #endif
  626. #ifndef Py_TPFLAGS_MAPPING
  627. #define Py_TPFLAGS_MAPPING 0
  628. #endif
  629. #ifndef Py_TPFLAGS_IMMUTABLETYPE
  630. #define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8)
  631. #endif
  632. #ifndef Py_TPFLAGS_DISALLOW_INSTANTIATION
  633. #define Py_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7)
  634. #endif
  635. #ifndef METH_STACKLESS
  636. #define METH_STACKLESS 0
  637. #endif
  638. #ifndef METH_FASTCALL
  639. #ifndef METH_FASTCALL
  640. #define METH_FASTCALL 0x80
  641. #endif
  642. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  643. typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
  644. Py_ssize_t nargs, PyObject *kwnames);
  645. #else
  646. #if PY_VERSION_HEX >= 0x030d00A4
  647. # define __Pyx_PyCFunctionFast PyCFunctionFast
  648. # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords
  649. #else
  650. # define __Pyx_PyCFunctionFast _PyCFunctionFast
  651. # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  652. #endif
  653. #endif
  654. #if CYTHON_METH_FASTCALL
  655. #define __Pyx_METH_FASTCALL METH_FASTCALL
  656. #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast
  657. #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords
  658. #else
  659. #define __Pyx_METH_FASTCALL METH_VARARGS
  660. #define __Pyx_PyCFunction_FastCall PyCFunction
  661. #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords
  662. #endif
  663. #if CYTHON_VECTORCALL
  664. #define __pyx_vectorcallfunc vectorcallfunc
  665. #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET
  666. #define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n))
  667. #else
  668. #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0
  669. #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n))
  670. #endif
  671. #if PY_VERSION_HEX >= 0x030900B1
  672. #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func)
  673. #else
  674. #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_Check(func)
  675. #endif
  676. #define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func)
  677. #if CYTHON_COMPILING_IN_CPYTHON
  678. #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth)
  679. #elif !CYTHON_COMPILING_IN_LIMITED_API
  680. #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func)
  681. #endif
  682. #if CYTHON_COMPILING_IN_CPYTHON
  683. #define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags)
  684. static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) {
  685. return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self;
  686. }
  687. #endif
  688. static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void (*cfunc)(void)) {
  689. #if CYTHON_COMPILING_IN_LIMITED_API
  690. return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
  691. #else
  692. return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
  693. #endif
  694. }
  695. #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc)
  696. #if PY_VERSION_HEX < 0x03090000 || (CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000)
  697. #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b))
  698. typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *);
  699. #else
  700. #define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b)
  701. #define __Pyx_PyCMethod PyCMethod
  702. #endif
  703. #ifndef METH_METHOD
  704. #define METH_METHOD 0x200
  705. #endif
  706. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  707. #define PyObject_Malloc(s) PyMem_Malloc(s)
  708. #define PyObject_Free(p) PyMem_Free(p)
  709. #define PyObject_Realloc(p) PyMem_Realloc(p)
  710. #endif
  711. #if CYTHON_COMPILING_IN_LIMITED_API
  712. #define __Pyx_PyFrame_SetLineNumber(frame, lineno)
  713. #elif CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
  714. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  715. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) GraalPyFrame_SetLineNumber((frame), (lineno))
  716. #elif CYTHON_COMPILING_IN_GRAAL
  717. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  718. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) _PyFrame_SetLineNumber((frame), (lineno))
  719. #else
  720. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  721. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  722. #endif
  723. #if CYTHON_COMPILING_IN_LIMITED_API
  724. #define __Pyx_PyThreadState_Current PyThreadState_Get()
  725. #elif !CYTHON_FAST_THREAD_STATE
  726. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  727. #elif PY_VERSION_HEX >= 0x030d00A1
  728. #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked()
  729. #else
  730. #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
  731. #endif
  732. #if CYTHON_USE_MODULE_STATE
  733. static CYTHON_INLINE void *__Pyx__PyModule_GetState(PyObject *op)
  734. {
  735. void *result;
  736. result = PyModule_GetState(op);
  737. if (!result)
  738. Py_FatalError("Couldn't find the module state");
  739. return result;
  740. }
  741. #define __Pyx_PyModule_GetState(o) (__pyx_mstatetype *)__Pyx__PyModule_GetState(o)
  742. #else
  743. #define __Pyx_PyModule_GetState(op) ((void)op,__pyx_mstate_global)
  744. #endif
  745. #define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE((PyObject *) obj), name, func_ctype)
  746. #define __Pyx_PyObject_TryGetSlot(obj, name, func_ctype) __Pyx_PyType_TryGetSlot(Py_TYPE(obj), name, func_ctype)
  747. #define __Pyx_PyObject_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(Py_TYPE(obj), sub, name, func_ctype)
  748. #define __Pyx_PyObject_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSubSlot(Py_TYPE(obj), sub, name, func_ctype)
  749. #if CYTHON_USE_TYPE_SLOTS
  750. #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name)
  751. #define __Pyx_PyType_TryGetSlot(type, name, func_ctype) __Pyx_PyType_GetSlot(type, name, func_ctype)
  752. #define __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) (((type)->sub) ? ((type)->sub->name) : NULL)
  753. #define __Pyx_PyType_TryGetSubSlot(type, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype)
  754. #else
  755. #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name))
  756. #define __Pyx_PyType_TryGetSlot(type, name, func_ctype)\
  757. ((__PYX_LIMITED_VERSION_HEX >= 0x030A0000 ||\
  758. (PyType_GetFlags(type) & Py_TPFLAGS_HEAPTYPE) || __Pyx_get_runtime_version() >= 0x030A0000) ?\
  759. __Pyx_PyType_GetSlot(type, name, func_ctype) : NULL)
  760. #define __Pyx_PyType_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSlot(obj, name, func_ctype)
  761. #define __Pyx_PyType_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSlot(obj, name, func_ctype)
  762. #endif
  763. #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
  764. #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
  765. #else
  766. #define __Pyx_PyDict_NewPresized(n) PyDict_New()
  767. #endif
  768. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  769. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  770. #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_UNICODE_INTERNALS
  771. #define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
  772. static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) {
  773. PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name);
  774. if (res == NULL) PyErr_Clear();
  775. return res;
  776. }
  777. #elif !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000
  778. #define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError
  779. #define __Pyx_PyDict_GetItemStr PyDict_GetItem
  780. #else
  781. static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) {
  782. #if CYTHON_COMPILING_IN_PYPY
  783. return PyDict_GetItem(dict, name);
  784. #else
  785. PyDictEntry *ep;
  786. PyDictObject *mp = (PyDictObject*) dict;
  787. long hash = ((PyStringObject *) name)->ob_shash;
  788. assert(hash != -1);
  789. ep = (mp->ma_lookup)(mp, name, hash);
  790. if (ep == NULL) {
  791. return NULL;
  792. }
  793. return ep->me_value;
  794. #endif
  795. }
  796. #define __Pyx_PyDict_GetItemStr PyDict_GetItem
  797. #endif
  798. #if CYTHON_USE_TYPE_SLOTS
  799. #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags)
  800. #define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0)
  801. #else
  802. #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp))
  803. #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature)
  804. #endif
  805. #define __Pyx_PyObject_GetIterNextFunc(iterator) __Pyx_PyObject_GetSlot(iterator, tp_iternext, iternextfunc)
  806. #if CYTHON_USE_TYPE_SPECS
  807. #define __Pyx_PyHeapTypeObject_GC_Del(obj) {\
  808. PyTypeObject *type = Py_TYPE((PyObject*)obj);\
  809. assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\
  810. PyObject_GC_Del(obj);\
  811. Py_DECREF(type);\
  812. }
  813. #else
  814. #define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj)
  815. #endif
  816. #if CYTHON_COMPILING_IN_LIMITED_API
  817. #define __Pyx_PyUnicode_READY(op) (0)
  818. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i)
  819. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U)
  820. #define __Pyx_PyUnicode_KIND(u) ((void)u, (0))
  821. #define __Pyx_PyUnicode_DATA(u) ((void*)u)
  822. #define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i))
  823. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u))
  824. #else
  825. #if PY_VERSION_HEX >= 0x030C0000
  826. #define __Pyx_PyUnicode_READY(op) (0)
  827. #else
  828. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  829. 0 : _PyUnicode_Ready((PyObject *)(op)))
  830. #endif
  831. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  832. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  833. #define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u))
  834. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  835. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  836. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch)
  837. #if PY_VERSION_HEX >= 0x030C0000
  838. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
  839. #else
  840. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
  841. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
  842. #else
  843. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  844. #endif
  845. #endif
  846. #endif
  847. #if CYTHON_COMPILING_IN_PYPY
  848. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  849. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  850. #else
  851. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  852. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  853. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  854. #endif
  855. #if CYTHON_COMPILING_IN_PYPY
  856. #if !defined(PyUnicode_DecodeUnicodeEscape)
  857. #define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors)
  858. #endif
  859. #if !defined(PyUnicode_Contains)
  860. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  861. #endif
  862. #if !defined(PyByteArray_Check)
  863. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  864. #endif
  865. #if !defined(PyObject_Format)
  866. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  867. #endif
  868. #endif
  869. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  870. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  871. #define __Pyx_PySequence_ListKeepNew(obj)\
  872. (likely(PyList_CheckExact(obj) && PyUnstable_Object_IsUniquelyReferenced(obj)) ? __Pyx_NewRef(obj) : PySequence_List(obj))
  873. #elif CYTHON_COMPILING_IN_CPYTHON
  874. #define __Pyx_PySequence_ListKeepNew(obj)\
  875. (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj))
  876. #else
  877. #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj)
  878. #endif
  879. #ifndef PySet_CheckExact
  880. #define PySet_CheckExact(obj) __Pyx_IS_TYPE(obj, &PySet_Type)
  881. #endif
  882. #if PY_VERSION_HEX >= 0x030900A4
  883. #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  884. #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
  885. #else
  886. #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  887. #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
  888. #endif
  889. enum __Pyx_ReferenceSharing {
  890. __Pyx_ReferenceSharing_DefinitelyUnique, // We created it so we know it's unshared - no need to check
  891. __Pyx_ReferenceSharing_OwnStrongReference,
  892. __Pyx_ReferenceSharing_FunctionArgument,
  893. __Pyx_ReferenceSharing_SharedReference, // Never trust it to be unshared because it's a global or similar
  894. };
  895. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX >= 0x030E0000
  896. #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing)\
  897. (sharing == __Pyx_ReferenceSharing_DefinitelyUnique ? 1 :\
  898. (sharing == __Pyx_ReferenceSharing_FunctionArgument ? PyUnstable_Object_IsUniqueReferencedTemporary(o) :\
  899. (sharing == __Pyx_ReferenceSharing_OwnStrongReference ? PyUnstable_Object_IsUniquelyReferenced(o) : 0)))
  900. #elif (CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) || CYTHON_COMPILING_IN_LIMITED_API
  901. #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)sharing), Py_REFCNT(o) == 1)
  902. #else
  903. #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)o), ((void)sharing), 0)
  904. #endif
  905. #if CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  906. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  907. #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i)
  908. #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS
  909. #define __Pyx_PyList_GetItemRef(o, i) (likely((i) >= 0) ? PySequence_GetItem(o, i) : (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
  910. #else
  911. #define __Pyx_PyList_GetItemRef(o, i) PySequence_ITEM(o, i)
  912. #endif
  913. #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS
  914. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  915. #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i)
  916. #else
  917. #define __Pyx_PyList_GetItemRef(o, i) __Pyx_XNewRef(PyList_GetItem(o, i))
  918. #endif
  919. #else
  920. #define __Pyx_PyList_GetItemRef(o, i) __Pyx_NewRef(PyList_GET_ITEM(o, i))
  921. #endif
  922. #if CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS && !CYTHON_COMPILING_IN_LIMITED_API && CYTHON_ASSUME_SAFE_MACROS
  923. #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) (__Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared) ?\
  924. __Pyx_NewRef(PyList_GET_ITEM(o, i)) : __Pyx_PyList_GetItemRef(o, i))
  925. #else
  926. #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) __Pyx_PyList_GetItemRef(o, i)
  927. #endif
  928. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  929. #define __Pyx_PyDict_GetItemRef(dict, key, result) PyDict_GetItemRef(dict, key, result)
  930. #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  931. static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) {
  932. *result = PyObject_GetItem(dict, key);
  933. if (*result == NULL) {
  934. if (PyErr_ExceptionMatches(PyExc_KeyError)) {
  935. PyErr_Clear();
  936. return 0;
  937. }
  938. return -1;
  939. }
  940. return 1;
  941. }
  942. #else
  943. static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) {
  944. *result = PyDict_GetItemWithError(dict, key);
  945. if (*result == NULL) {
  946. return PyErr_Occurred() ? -1 : 0;
  947. }
  948. Py_INCREF(*result);
  949. return 1;
  950. }
  951. #endif
  952. #if defined(CYTHON_DEBUG_VISIT_CONST) && CYTHON_DEBUG_VISIT_CONST
  953. #define __Pyx_VISIT_CONST(obj) Py_VISIT(obj)
  954. #else
  955. #define __Pyx_VISIT_CONST(obj)
  956. #endif
  957. #if CYTHON_ASSUME_SAFE_MACROS
  958. #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i)
  959. #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
  960. #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0))
  961. #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GET_ITEM(o, i)
  962. #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0))
  963. #define __Pyx_PyList_GET_ITEM(o, i) PyList_GET_ITEM(o, i)
  964. #else
  965. #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i)
  966. #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
  967. #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v)
  968. #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GetItem(o, i)
  969. #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v)
  970. #define __Pyx_PyList_GET_ITEM(o, i) PyList_GetItem(o, i)
  971. #endif
  972. #if CYTHON_ASSUME_SAFE_SIZE
  973. #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o)
  974. #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o)
  975. #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o)
  976. #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o)
  977. #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o)
  978. #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GET_LENGTH(o)
  979. #else
  980. #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o)
  981. #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o)
  982. #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o)
  983. #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o)
  984. #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o)
  985. #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GetLength(o)
  986. #endif
  987. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_InternFromString)
  988. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  989. #endif
  990. #define __Pyx_PyLong_FromHash_t PyLong_FromSsize_t
  991. #define __Pyx_PyLong_AsHash_t __Pyx_PyIndex_AsSsize_t
  992. #if __PYX_LIMITED_VERSION_HEX >= 0x030A0000
  993. #define __Pyx_PySendResult PySendResult
  994. #else
  995. typedef enum {
  996. PYGEN_RETURN = 0,
  997. PYGEN_ERROR = -1,
  998. PYGEN_NEXT = 1,
  999. } __Pyx_PySendResult;
  1000. #endif
  1001. #if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030A00A3
  1002. typedef __Pyx_PySendResult (*__Pyx_pyiter_sendfunc)(PyObject *iter, PyObject *value, PyObject **result);
  1003. #else
  1004. #define __Pyx_pyiter_sendfunc sendfunc
  1005. #endif
  1006. #if !CYTHON_USE_AM_SEND
  1007. #define __PYX_HAS_PY_AM_SEND 0
  1008. #elif __PYX_LIMITED_VERSION_HEX >= 0x030A0000
  1009. #define __PYX_HAS_PY_AM_SEND 1
  1010. #else
  1011. #define __PYX_HAS_PY_AM_SEND 2 // our own backported implementation
  1012. #endif
  1013. #if __PYX_HAS_PY_AM_SEND < 2
  1014. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  1015. #else
  1016. typedef struct {
  1017. unaryfunc am_await;
  1018. unaryfunc am_aiter;
  1019. unaryfunc am_anext;
  1020. __Pyx_pyiter_sendfunc am_send;
  1021. } __Pyx_PyAsyncMethodsStruct;
  1022. #define __Pyx_SlotTpAsAsync(s) ((PyAsyncMethods*)(s))
  1023. #endif
  1024. #if CYTHON_USE_AM_SEND && PY_VERSION_HEX < 0x030A00F0
  1025. #define __Pyx_TPFLAGS_HAVE_AM_SEND (1UL << 21)
  1026. #else
  1027. #define __Pyx_TPFLAGS_HAVE_AM_SEND (0)
  1028. #endif
  1029. #if PY_VERSION_HEX >= 0x03090000
  1030. #define __Pyx_PyInterpreterState_Get() PyInterpreterState_Get()
  1031. #else
  1032. #define __Pyx_PyInterpreterState_Get() PyThreadState_Get()->interp
  1033. #endif
  1034. #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030A0000
  1035. #ifdef __cplusplus
  1036. extern "C"
  1037. #endif
  1038. PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize);
  1039. #endif
  1040. #if CYTHON_COMPILING_IN_LIMITED_API
  1041. static int __Pyx_init_co_variable(PyObject *inspect, const char* name, int *write_to) {
  1042. int value;
  1043. PyObject *py_value = PyObject_GetAttrString(inspect, name);
  1044. if (!py_value) return 0;
  1045. value = (int) PyLong_AsLong(py_value);
  1046. Py_DECREF(py_value);
  1047. *write_to = value;
  1048. return value != -1 || !PyErr_Occurred();
  1049. }
  1050. static int __Pyx_init_co_variables(void) {
  1051. PyObject *inspect;
  1052. int result;
  1053. inspect = PyImport_ImportModule("inspect");
  1054. result =
  1055. #if !defined(CO_OPTIMIZED)
  1056. __Pyx_init_co_variable(inspect, "CO_OPTIMIZED", &CO_OPTIMIZED) &&
  1057. #endif
  1058. #if !defined(CO_NEWLOCALS)
  1059. __Pyx_init_co_variable(inspect, "CO_NEWLOCALS", &CO_NEWLOCALS) &&
  1060. #endif
  1061. #if !defined(CO_VARARGS)
  1062. __Pyx_init_co_variable(inspect, "CO_VARARGS", &CO_VARARGS) &&
  1063. #endif
  1064. #if !defined(CO_VARKEYWORDS)
  1065. __Pyx_init_co_variable(inspect, "CO_VARKEYWORDS", &CO_VARKEYWORDS) &&
  1066. #endif
  1067. #if !defined(CO_ASYNC_GENERATOR)
  1068. __Pyx_init_co_variable(inspect, "CO_ASYNC_GENERATOR", &CO_ASYNC_GENERATOR) &&
  1069. #endif
  1070. #if !defined(CO_GENERATOR)
  1071. __Pyx_init_co_variable(inspect, "CO_GENERATOR", &CO_GENERATOR) &&
  1072. #endif
  1073. #if !defined(CO_COROUTINE)
  1074. __Pyx_init_co_variable(inspect, "CO_COROUTINE", &CO_COROUTINE) &&
  1075. #endif
  1076. 1;
  1077. Py_DECREF(inspect);
  1078. return result ? 0 : -1;
  1079. }
  1080. #else
  1081. static int __Pyx_init_co_variables(void) {
  1082. return 0; // It's a limited API-only feature
  1083. }
  1084. #endif
  1085. /* MathInitCode */
  1086. #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
  1087. #ifndef _USE_MATH_DEFINES
  1088. #define _USE_MATH_DEFINES
  1089. #endif
  1090. #endif
  1091. #include <math.h>
  1092. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  1093. #define __Pyx_truncl trunc
  1094. #else
  1095. #define __Pyx_truncl truncl
  1096. #endif
  1097. #ifndef CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  1098. #define CYTHON_CLINE_IN_TRACEBACK_RUNTIME 0
  1099. #endif
  1100. #ifndef CYTHON_CLINE_IN_TRACEBACK
  1101. #define CYTHON_CLINE_IN_TRACEBACK CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  1102. #endif
  1103. #if CYTHON_CLINE_IN_TRACEBACK
  1104. #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; __pyx_clineno = __LINE__; (void) __pyx_clineno; }
  1105. #else
  1106. #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; (void) __pyx_clineno; }
  1107. #endif
  1108. #define __PYX_ERR(f_index, lineno, Ln_error) \
  1109. { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
  1110. #ifdef CYTHON_EXTERN_C
  1111. #undef __PYX_EXTERN_C
  1112. #define __PYX_EXTERN_C CYTHON_EXTERN_C
  1113. #elif defined(__PYX_EXTERN_C)
  1114. #ifdef _MSC_VER
  1115. #pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.")
  1116. #else
  1117. #warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.
  1118. #endif
  1119. #else
  1120. #ifdef __cplusplus
  1121. #define __PYX_EXTERN_C extern "C"
  1122. #else
  1123. #define __PYX_EXTERN_C extern
  1124. #endif
  1125. #endif
  1126. #define __PYX_HAVE__fontTools__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. #ifdef CYTHON_FREETHREADING_COMPATIBLE
  1136. #if CYTHON_FREETHREADING_COMPATIBLE
  1137. #define __Pyx_FREETHREADING_COMPATIBLE Py_MOD_GIL_NOT_USED
  1138. #else
  1139. #define __Pyx_FREETHREADING_COMPATIBLE Py_MOD_GIL_USED
  1140. #endif
  1141. #else
  1142. #define __Pyx_FREETHREADING_COMPATIBLE Py_MOD_GIL_USED
  1143. #endif
  1144. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  1145. #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
  1146. #define __PYX_DEFAULT_STRING_ENCODING ""
  1147. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  1148. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  1149. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  1150. #define __Pyx_long_cast(x) ((long)x)
  1151. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  1152. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  1153. (sizeof(type) > sizeof(Py_ssize_t) &&\
  1154. likely(v < (type)PY_SSIZE_T_MAX ||\
  1155. v == (type)PY_SSIZE_T_MAX) &&\
  1156. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  1157. v == (type)PY_SSIZE_T_MIN))) ||\
  1158. (sizeof(type) == sizeof(Py_ssize_t) &&\
  1159. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  1160. v == (type)PY_SSIZE_T_MAX))) )
  1161. static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
  1162. return (size_t) i < (size_t) limit;
  1163. }
  1164. #if defined (__cplusplus) && __cplusplus >= 201103L
  1165. #include <cstdlib>
  1166. #define __Pyx_sst_abs(value) std::abs(value)
  1167. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  1168. #define __Pyx_sst_abs(value) abs(value)
  1169. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  1170. #define __Pyx_sst_abs(value) labs(value)
  1171. #elif defined (_MSC_VER)
  1172. #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
  1173. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  1174. #define __Pyx_sst_abs(value) llabs(value)
  1175. #elif defined (__GNUC__)
  1176. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  1177. #else
  1178. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  1179. #endif
  1180. static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s);
  1181. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  1182. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  1183. static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*);
  1184. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  1185. #define __Pyx_PyBytes_FromString PyBytes_FromString
  1186. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  1187. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  1188. #if CYTHON_ASSUME_SAFE_MACROS
  1189. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
  1190. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
  1191. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
  1192. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
  1193. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
  1194. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
  1195. #define __Pyx_PyByteArray_AsString(s) PyByteArray_AS_STRING(s)
  1196. #else
  1197. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AsString(s))
  1198. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AsString(s))
  1199. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AsString(s))
  1200. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AsString(s))
  1201. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AsString(s))
  1202. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AsString(s))
  1203. #define __Pyx_PyByteArray_AsString(s) PyByteArray_AsString(s)
  1204. #endif
  1205. #define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
  1206. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
  1207. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
  1208. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  1209. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  1210. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  1211. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  1212. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  1213. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  1214. #define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o)
  1215. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  1216. static CYTHON_INLINE PyObject *__Pyx_NewRef(PyObject *obj) {
  1217. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_NewRef)
  1218. return Py_NewRef(obj);
  1219. #else
  1220. Py_INCREF(obj);
  1221. return obj;
  1222. #endif
  1223. }
  1224. static CYTHON_INLINE PyObject *__Pyx_XNewRef(PyObject *obj) {
  1225. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_XNewRef)
  1226. return Py_XNewRef(obj);
  1227. #else
  1228. Py_XINCREF(obj);
  1229. return obj;
  1230. #endif
  1231. }
  1232. static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b);
  1233. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
  1234. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  1235. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
  1236. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x);
  1237. #define __Pyx_PySequence_Tuple(obj)\
  1238. (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
  1239. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  1240. static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t);
  1241. static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
  1242. #if CYTHON_ASSUME_SAFE_MACROS
  1243. #define __Pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  1244. #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AS_DOUBLE(x)
  1245. #else
  1246. #define __Pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  1247. #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AsDouble(x)
  1248. #endif
  1249. #define __Pyx_PyFloat_AsFloat(x) ((float) __Pyx_PyFloat_AsDouble(x))
  1250. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  1251. #if CYTHON_USE_PYLONG_INTERNALS
  1252. #if PY_VERSION_HEX >= 0x030C00A7
  1253. #ifndef _PyLong_SIGN_MASK
  1254. #define _PyLong_SIGN_MASK 3
  1255. #endif
  1256. #ifndef _PyLong_NON_SIZE_BITS
  1257. #define _PyLong_NON_SIZE_BITS 3
  1258. #endif
  1259. #define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK)
  1260. #define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0)
  1261. #define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x))
  1262. #define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1)
  1263. #define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0)
  1264. #define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0])
  1265. #define __Pyx_PyLong_DigitCount(x) ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS))
  1266. #define __Pyx_PyLong_SignedDigitCount(x)\
  1267. ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x))
  1268. #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue)
  1269. #define __Pyx_PyLong_IsCompact(x) PyUnstable_Long_IsCompact((PyLongObject*) x)
  1270. #define __Pyx_PyLong_CompactValue(x) PyUnstable_Long_CompactValue((PyLongObject*) x)
  1271. #else
  1272. #define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS))
  1273. #define __Pyx_PyLong_CompactValue(x) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0])
  1274. #endif
  1275. typedef Py_ssize_t __Pyx_compact_pylong;
  1276. typedef size_t __Pyx_compact_upylong;
  1277. #else
  1278. #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0)
  1279. #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0)
  1280. #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0)
  1281. #define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0)
  1282. #define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0])
  1283. #define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x))
  1284. #define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x)
  1285. #define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1)
  1286. #define __Pyx_PyLong_CompactValue(x)\
  1287. ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0]))
  1288. typedef sdigit __Pyx_compact_pylong;
  1289. typedef digit __Pyx_compact_upylong;
  1290. #endif
  1291. #if PY_VERSION_HEX >= 0x030C00A5
  1292. #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit)
  1293. #else
  1294. #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit)
  1295. #endif
  1296. #endif
  1297. #if __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
  1298. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  1299. #elif __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  1300. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeASCII(c_str, size, NULL)
  1301. #else
  1302. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  1303. #endif
  1304. /* Test for GCC > 2.95 */
  1305. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  1306. #define likely(x) __builtin_expect(!!(x), 1)
  1307. #define unlikely(x) __builtin_expect(!!(x), 0)
  1308. #else /* !__GNUC__ or GCC < 2.95 */
  1309. #define likely(x) (x)
  1310. #define unlikely(x) (x)
  1311. #endif /* __GNUC__ */
  1312. /* PretendToInitialize */
  1313. #ifdef __cplusplus
  1314. #if __cplusplus > 201103L
  1315. #include <type_traits>
  1316. #endif
  1317. template <typename T>
  1318. static void __Pyx_pretend_to_initialize(T* ptr) {
  1319. #if __cplusplus > 201103L
  1320. if ((std::is_trivially_default_constructible<T>::value))
  1321. #endif
  1322. *ptr = T();
  1323. (void)ptr;
  1324. }
  1325. #else
  1326. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  1327. #endif
  1328. #if !CYTHON_USE_MODULE_STATE
  1329. static PyObject *__pyx_m = NULL;
  1330. #endif
  1331. static int __pyx_lineno;
  1332. static int __pyx_clineno = 0;
  1333. static const char * const __pyx_cfilenm = __FILE__;
  1334. static const char *__pyx_filename;
  1335. /* Header.proto */
  1336. #if !defined(CYTHON_CCOMPLEX)
  1337. #if defined(__cplusplus)
  1338. #define CYTHON_CCOMPLEX 1
  1339. #elif (defined(_Complex_I) && !defined(_MSC_VER)) || ((defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_COMPLEX__) && !defined(_MSC_VER))
  1340. #define CYTHON_CCOMPLEX 1
  1341. #else
  1342. #define CYTHON_CCOMPLEX 0
  1343. #endif
  1344. #endif
  1345. #if CYTHON_CCOMPLEX
  1346. #ifdef __cplusplus
  1347. #include <complex>
  1348. #else
  1349. #include <complex.h>
  1350. #endif
  1351. #endif
  1352. #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  1353. #undef _Complex_I
  1354. #define _Complex_I 1.0fj
  1355. #endif
  1356. /* #### Code section: filename_table ### */
  1357. static const char* const __pyx_f[] = {
  1358. "Lib/fontTools/cu2qu/cu2qu.py",
  1359. };
  1360. /* #### Code section: utility_code_proto_before_types ### */
  1361. /* Atomics.proto (used by UnpackUnboundCMethod) */
  1362. #include <pythread.h>
  1363. #ifndef CYTHON_ATOMICS
  1364. #define CYTHON_ATOMICS 1
  1365. #endif
  1366. #define __PYX_CYTHON_ATOMICS_ENABLED() CYTHON_ATOMICS
  1367. #define __PYX_GET_CYTHON_COMPILING_IN_CPYTHON_FREETHREADING() CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1368. #define __pyx_atomic_int_type int
  1369. #define __pyx_nonatomic_int_type int
  1370. #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\
  1371. (__STDC_VERSION__ >= 201112L) &&\
  1372. !defined(__STDC_NO_ATOMICS__))
  1373. #include <stdatomic.h>
  1374. #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\
  1375. (__cplusplus >= 201103L) ||\
  1376. (defined(_MSC_VER) && _MSC_VER >= 1700)))
  1377. #include <atomic>
  1378. #endif
  1379. #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\
  1380. (__STDC_VERSION__ >= 201112L) &&\
  1381. !defined(__STDC_NO_ATOMICS__) &&\
  1382. ATOMIC_INT_LOCK_FREE == 2)
  1383. #undef __pyx_atomic_int_type
  1384. #define __pyx_atomic_int_type atomic_int
  1385. #define __pyx_atomic_ptr_type atomic_uintptr_t
  1386. #define __pyx_nonatomic_ptr_type uintptr_t
  1387. #define __pyx_atomic_incr_relaxed(value) atomic_fetch_add_explicit(value, 1, memory_order_relaxed)
  1388. #define __pyx_atomic_incr_acq_rel(value) atomic_fetch_add_explicit(value, 1, memory_order_acq_rel)
  1389. #define __pyx_atomic_decr_acq_rel(value) atomic_fetch_sub_explicit(value, 1, memory_order_acq_rel)
  1390. #define __pyx_atomic_sub(value, arg) atomic_fetch_sub(value, arg)
  1391. #define __pyx_atomic_int_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired)
  1392. #define __pyx_atomic_load(value) atomic_load(value)
  1393. #define __pyx_atomic_store(value, new_value) atomic_store(value, new_value)
  1394. #define __pyx_atomic_pointer_load_relaxed(value) atomic_load_explicit(value, memory_order_relaxed)
  1395. #define __pyx_atomic_pointer_load_acquire(value) atomic_load_explicit(value, memory_order_acquire)
  1396. #define __pyx_atomic_pointer_exchange(value, new_value) atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value)
  1397. #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired)
  1398. #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER)
  1399. #pragma message ("Using standard C atomics")
  1400. #elif defined(__PYX_DEBUG_ATOMICS)
  1401. #warning "Using standard C atomics"
  1402. #endif
  1403. #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\
  1404. (__cplusplus >= 201103L) ||\
  1405. \
  1406. (defined(_MSC_VER) && _MSC_VER >= 1700)) &&\
  1407. ATOMIC_INT_LOCK_FREE == 2)
  1408. #undef __pyx_atomic_int_type
  1409. #define __pyx_atomic_int_type std::atomic_int
  1410. #define __pyx_atomic_ptr_type std::atomic_uintptr_t
  1411. #define __pyx_nonatomic_ptr_type uintptr_t
  1412. #define __pyx_atomic_incr_relaxed(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_relaxed)
  1413. #define __pyx_atomic_incr_acq_rel(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_acq_rel)
  1414. #define __pyx_atomic_decr_acq_rel(value) std::atomic_fetch_sub_explicit(value, 1, std::memory_order_acq_rel)
  1415. #define __pyx_atomic_sub(value, arg) std::atomic_fetch_sub(value, arg)
  1416. #define __pyx_atomic_int_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired)
  1417. #define __pyx_atomic_load(value) std::atomic_load(value)
  1418. #define __pyx_atomic_store(value, new_value) std::atomic_store(value, new_value)
  1419. #define __pyx_atomic_pointer_load_relaxed(value) std::atomic_load_explicit(value, std::memory_order_relaxed)
  1420. #define __pyx_atomic_pointer_load_acquire(value) std::atomic_load_explicit(value, std::memory_order_acquire)
  1421. #define __pyx_atomic_pointer_exchange(value, new_value) std::atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value)
  1422. #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired)
  1423. #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER)
  1424. #pragma message ("Using standard C++ atomics")
  1425. #elif defined(__PYX_DEBUG_ATOMICS)
  1426. #warning "Using standard C++ atomics"
  1427. #endif
  1428. #elif CYTHON_ATOMICS && (__GNUC__ >= 5 || (__GNUC__ == 4 &&\
  1429. (__GNUC_MINOR__ > 1 ||\
  1430. (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ >= 2))))
  1431. #define __pyx_atomic_ptr_type void*
  1432. #define __pyx_nonatomic_ptr_type void*
  1433. #define __pyx_atomic_incr_relaxed(value) __sync_fetch_and_add(value, 1)
  1434. #define __pyx_atomic_incr_acq_rel(value) __sync_fetch_and_add(value, 1)
  1435. #define __pyx_atomic_decr_acq_rel(value) __sync_fetch_and_sub(value, 1)
  1436. #define __pyx_atomic_sub(value, arg) __sync_fetch_and_sub(value, arg)
  1437. static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) {
  1438. __pyx_nonatomic_int_type old = __sync_val_compare_and_swap(value, *expected, desired);
  1439. int result = old == *expected;
  1440. *expected = old;
  1441. return result;
  1442. }
  1443. #define __pyx_atomic_load(value) __sync_fetch_and_add(value, 0)
  1444. #define __pyx_atomic_store(value, new_value) __sync_lock_test_and_set(value, new_value)
  1445. #define __pyx_atomic_pointer_load_relaxed(value) __sync_fetch_and_add(value, 0)
  1446. #define __pyx_atomic_pointer_load_acquire(value) __sync_fetch_and_add(value, 0)
  1447. #define __pyx_atomic_pointer_exchange(value, new_value) __sync_lock_test_and_set(value, (__pyx_atomic_ptr_type)new_value)
  1448. static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) {
  1449. __pyx_nonatomic_ptr_type old = __sync_val_compare_and_swap(value, *expected, desired);
  1450. int result = old == *expected;
  1451. *expected = old;
  1452. return result;
  1453. }
  1454. #ifdef __PYX_DEBUG_ATOMICS
  1455. #warning "Using GNU atomics"
  1456. #endif
  1457. #elif CYTHON_ATOMICS && defined(_MSC_VER)
  1458. #include <intrin.h>
  1459. #undef __pyx_atomic_int_type
  1460. #define __pyx_atomic_int_type long
  1461. #define __pyx_atomic_ptr_type void*
  1462. #undef __pyx_nonatomic_int_type
  1463. #define __pyx_nonatomic_int_type long
  1464. #define __pyx_nonatomic_ptr_type void*
  1465. #pragma intrinsic (_InterlockedExchangeAdd, _InterlockedExchange, _InterlockedCompareExchange, _InterlockedCompareExchangePointer, _InterlockedExchangePointer)
  1466. #define __pyx_atomic_incr_relaxed(value) _InterlockedExchangeAdd(value, 1)
  1467. #define __pyx_atomic_incr_acq_rel(value) _InterlockedExchangeAdd(value, 1)
  1468. #define __pyx_atomic_decr_acq_rel(value) _InterlockedExchangeAdd(value, -1)
  1469. #define __pyx_atomic_sub(value, arg) _InterlockedExchangeAdd(value, -arg)
  1470. static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) {
  1471. __pyx_nonatomic_int_type old = _InterlockedCompareExchange(value, desired, *expected);
  1472. int result = old == *expected;
  1473. *expected = old;
  1474. return result;
  1475. }
  1476. #define __pyx_atomic_load(value) _InterlockedExchangeAdd(value, 0)
  1477. #define __pyx_atomic_store(value, new_value) _InterlockedExchange(value, new_value)
  1478. #define __pyx_atomic_pointer_load_relaxed(value) *(void * volatile *)value
  1479. #define __pyx_atomic_pointer_load_acquire(value) _InterlockedCompareExchangePointer(value, 0, 0)
  1480. #define __pyx_atomic_pointer_exchange(value, new_value) _InterlockedExchangePointer(value, (__pyx_atomic_ptr_type)new_value)
  1481. static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) {
  1482. __pyx_atomic_ptr_type old = _InterlockedCompareExchangePointer(value, desired, *expected);
  1483. int result = old == *expected;
  1484. *expected = old;
  1485. return result;
  1486. }
  1487. #ifdef __PYX_DEBUG_ATOMICS
  1488. #pragma message ("Using MSVC atomics")
  1489. #endif
  1490. #else
  1491. #undef CYTHON_ATOMICS
  1492. #define CYTHON_ATOMICS 0
  1493. #ifdef __PYX_DEBUG_ATOMICS
  1494. #warning "Not using atomics"
  1495. #endif
  1496. #endif
  1497. /* CriticalSectionsDefinition.proto (used by CriticalSections) */
  1498. #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1499. #define __Pyx_PyCriticalSection void*
  1500. #define __Pyx_PyCriticalSection2 void*
  1501. #define __Pyx_PyCriticalSection_End(cs)
  1502. #define __Pyx_PyCriticalSection2_End(cs)
  1503. #else
  1504. #define __Pyx_PyCriticalSection PyCriticalSection
  1505. #define __Pyx_PyCriticalSection2 PyCriticalSection2
  1506. #define __Pyx_PyCriticalSection_End PyCriticalSection_End
  1507. #define __Pyx_PyCriticalSection2_End PyCriticalSection2_End
  1508. #endif
  1509. /* CriticalSections.proto (used by ParseKeywordsImpl) */
  1510. #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1511. #define __Pyx_PyCriticalSection_Begin(cs, arg) (void)(cs)
  1512. #define __Pyx_PyCriticalSection2_Begin(cs, arg1, arg2) (void)(cs)
  1513. #else
  1514. #define __Pyx_PyCriticalSection_Begin PyCriticalSection_Begin
  1515. #define __Pyx_PyCriticalSection2_Begin PyCriticalSection2_Begin
  1516. #endif
  1517. #if PY_VERSION_HEX < 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
  1518. #define __Pyx_BEGIN_CRITICAL_SECTION(o) {
  1519. #define __Pyx_END_CRITICAL_SECTION() }
  1520. #else
  1521. #define __Pyx_BEGIN_CRITICAL_SECTION Py_BEGIN_CRITICAL_SECTION
  1522. #define __Pyx_END_CRITICAL_SECTION Py_END_CRITICAL_SECTION
  1523. #endif
  1524. /* IncludeStructmemberH.proto (used by FixUpExtensionType) */
  1525. #include <structmember.h>
  1526. /* #### Code section: numeric_typedefs ### */
  1527. /* #### Code section: complex_type_declarations ### */
  1528. /* Declarations.proto */
  1529. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  1530. #ifdef __cplusplus
  1531. typedef ::std::complex< double > __pyx_t_double_complex;
  1532. #else
  1533. typedef double _Complex __pyx_t_double_complex;
  1534. #endif
  1535. #else
  1536. typedef struct { double real, imag; } __pyx_t_double_complex;
  1537. #endif
  1538. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
  1539. /* #### Code section: type_declarations ### */
  1540. /*--- Type declarations ---*/
  1541. struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen;
  1542. /* "fontTools/cu2qu/cu2qu.py":150
  1543. *
  1544. *
  1545. * @cython.locals( # <<<<<<<<<<<<<<
  1546. * p0=cython.complex,
  1547. * p1=cython.complex,
  1548. */
  1549. struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen {
  1550. PyObject_HEAD
  1551. __pyx_t_double_complex __pyx_v_a;
  1552. __pyx_t_double_complex __pyx_v_a1;
  1553. __pyx_t_double_complex __pyx_v_b;
  1554. __pyx_t_double_complex __pyx_v_b1;
  1555. __pyx_t_double_complex __pyx_v_c;
  1556. __pyx_t_double_complex __pyx_v_c1;
  1557. __pyx_t_double_complex __pyx_v_d;
  1558. __pyx_t_double_complex __pyx_v_d1;
  1559. double __pyx_v_delta_2;
  1560. double __pyx_v_delta_3;
  1561. double __pyx_v_dt;
  1562. int __pyx_v_i;
  1563. int __pyx_v_n;
  1564. __pyx_t_double_complex __pyx_v_p0;
  1565. __pyx_t_double_complex __pyx_v_p1;
  1566. __pyx_t_double_complex __pyx_v_p2;
  1567. __pyx_t_double_complex __pyx_v_p3;
  1568. double __pyx_v_t1;
  1569. double __pyx_v_t1_2;
  1570. int __pyx_t_0;
  1571. int __pyx_t_1;
  1572. int __pyx_t_2;
  1573. };
  1574. /* #### Code section: utility_code_proto ### */
  1575. /* --- Runtime support code (head) --- */
  1576. /* Refnanny.proto */
  1577. #ifndef CYTHON_REFNANNY
  1578. #define CYTHON_REFNANNY 0
  1579. #endif
  1580. #if CYTHON_REFNANNY
  1581. typedef struct {
  1582. void (*INCREF)(void*, PyObject*, Py_ssize_t);
  1583. void (*DECREF)(void*, PyObject*, Py_ssize_t);
  1584. void (*GOTREF)(void*, PyObject*, Py_ssize_t);
  1585. void (*GIVEREF)(void*, PyObject*, Py_ssize_t);
  1586. void* (*SetupContext)(const char*, Py_ssize_t, const char*);
  1587. void (*FinishContext)(void**);
  1588. } __Pyx_RefNannyAPIStruct;
  1589. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  1590. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  1591. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  1592. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1593. if (acquire_gil) {\
  1594. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1595. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\
  1596. PyGILState_Release(__pyx_gilstate_save);\
  1597. } else {\
  1598. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\
  1599. }
  1600. #define __Pyx_RefNannyFinishContextNogil() {\
  1601. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1602. __Pyx_RefNannyFinishContext();\
  1603. PyGILState_Release(__pyx_gilstate_save);\
  1604. }
  1605. #define __Pyx_RefNannyFinishContextNogil() {\
  1606. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1607. __Pyx_RefNannyFinishContext();\
  1608. PyGILState_Release(__pyx_gilstate_save);\
  1609. }
  1610. #define __Pyx_RefNannyFinishContext()\
  1611. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  1612. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1613. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1614. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1615. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1616. #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0)
  1617. #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0)
  1618. #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0)
  1619. #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0)
  1620. #else
  1621. #define __Pyx_RefNannyDeclarations
  1622. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  1623. #define __Pyx_RefNannyFinishContextNogil()
  1624. #define __Pyx_RefNannyFinishContext()
  1625. #define __Pyx_INCREF(r) Py_INCREF(r)
  1626. #define __Pyx_DECREF(r) Py_DECREF(r)
  1627. #define __Pyx_GOTREF(r)
  1628. #define __Pyx_GIVEREF(r)
  1629. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  1630. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  1631. #define __Pyx_XGOTREF(r)
  1632. #define __Pyx_XGIVEREF(r)
  1633. #endif
  1634. #define __Pyx_Py_XDECREF_SET(r, v) do {\
  1635. PyObject *tmp = (PyObject *) r;\
  1636. r = v; Py_XDECREF(tmp);\
  1637. } while (0)
  1638. #define __Pyx_XDECREF_SET(r, v) do {\
  1639. PyObject *tmp = (PyObject *) r;\
  1640. r = v; __Pyx_XDECREF(tmp);\
  1641. } while (0)
  1642. #define __Pyx_DECREF_SET(r, v) do {\
  1643. PyObject *tmp = (PyObject *) r;\
  1644. r = v; __Pyx_DECREF(tmp);\
  1645. } while (0)
  1646. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  1647. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  1648. /* IncludeStdlibH.proto */
  1649. #include <stdlib.h>
  1650. /* PyObjectCall.proto (used by PyObjectFastCall) */
  1651. #if CYTHON_COMPILING_IN_CPYTHON
  1652. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  1653. #else
  1654. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  1655. #endif
  1656. /* PyObjectCallMethO.proto (used by PyObjectFastCall) */
  1657. #if CYTHON_COMPILING_IN_CPYTHON
  1658. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  1659. #endif
  1660. /* PyObjectFastCall.proto */
  1661. #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL)
  1662. static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs);
  1663. /* PyLongCompare.proto */
  1664. static CYTHON_INLINE int __Pyx_PyLong_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
  1665. /* RaiseTooManyValuesToUnpack.proto */
  1666. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
  1667. /* RaiseNeedMoreValuesToUnpack.proto */
  1668. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
  1669. /* PyThreadStateGet.proto (used by PyErrFetchRestore) */
  1670. #if CYTHON_FAST_THREAD_STATE
  1671. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  1672. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  1673. #if PY_VERSION_HEX >= 0x030C00A6
  1674. #define __Pyx_PyErr_Occurred() (__pyx_tstate->current_exception != NULL)
  1675. #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL)
  1676. #else
  1677. #define __Pyx_PyErr_Occurred() (__pyx_tstate->curexc_type != NULL)
  1678. #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->curexc_type)
  1679. #endif
  1680. #else
  1681. #define __Pyx_PyThreadState_declare
  1682. #define __Pyx_PyThreadState_assign
  1683. #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL)
  1684. #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred()
  1685. #endif
  1686. /* PyErrFetchRestore.proto (used by IterFinish) */
  1687. #if CYTHON_FAST_THREAD_STATE
  1688. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  1689. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  1690. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  1691. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  1692. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  1693. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1694. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1695. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6
  1696. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  1697. #else
  1698. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1699. #endif
  1700. #else
  1701. #define __Pyx_PyErr_Clear() PyErr_Clear()
  1702. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1703. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  1704. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  1705. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  1706. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  1707. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  1708. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  1709. #endif
  1710. /* IterFinish.proto */
  1711. static CYTHON_INLINE int __Pyx_IterFinish(void);
  1712. /* UnpackItemEndCheck.proto */
  1713. static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
  1714. /* GetItemInt.proto */
  1715. #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  1716. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1717. __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck, unsafe_shared) :\
  1718. (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
  1719. __Pyx_GetItemInt_Generic(o, to_py_func(i))))
  1720. #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  1721. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1722. __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\
  1723. (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
  1724. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  1725. int wraparound, int boundscheck, int unsafe_shared);
  1726. #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  1727. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1728. __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\
  1729. (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
  1730. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  1731. int wraparound, int boundscheck, int unsafe_shared);
  1732. static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
  1733. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
  1734. int is_list, int wraparound, int boundscheck, int unsafe_shared);
  1735. /* PyErrExceptionMatches.proto (used by PyObjectGetAttrStrNoError) */
  1736. #if CYTHON_FAST_THREAD_STATE
  1737. #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
  1738. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
  1739. #else
  1740. #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
  1741. #endif
  1742. /* PyObjectGetAttrStr.proto (used by PyObjectGetAttrStrNoError) */
  1743. #if CYTHON_USE_TYPE_SLOTS
  1744. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  1745. #else
  1746. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  1747. #endif
  1748. /* PyObjectGetAttrStrNoError.proto (used by GetBuiltinName) */
  1749. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
  1750. /* GetBuiltinName.proto (used by GetModuleGlobalName) */
  1751. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  1752. /* PyDictVersioning.proto (used by GetModuleGlobalName) */
  1753. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  1754. #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
  1755. #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
  1756. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
  1757. (version_var) = __PYX_GET_DICT_VERSION(dict);\
  1758. (cache_var) = (value);
  1759. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
  1760. static PY_UINT64_T __pyx_dict_version = 0;\
  1761. static PyObject *__pyx_dict_cached_value = NULL;\
  1762. if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
  1763. (VAR) = __Pyx_XNewRef(__pyx_dict_cached_value);\
  1764. } else {\
  1765. (VAR) = __pyx_dict_cached_value = (LOOKUP);\
  1766. __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
  1767. }\
  1768. }
  1769. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
  1770. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
  1771. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
  1772. #else
  1773. #define __PYX_GET_DICT_VERSION(dict) (0)
  1774. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
  1775. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
  1776. #endif
  1777. /* GetModuleGlobalName.proto */
  1778. #if CYTHON_USE_DICT_VERSIONS
  1779. #define __Pyx_GetModuleGlobalName(var, name) do {\
  1780. static PY_UINT64_T __pyx_dict_version = 0;\
  1781. static PyObject *__pyx_dict_cached_value = NULL;\
  1782. (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_mstate_global->__pyx_d))) ?\
  1783. (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
  1784. __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  1785. } while(0)
  1786. #define __Pyx_GetModuleGlobalNameUncached(var, name) do {\
  1787. PY_UINT64_T __pyx_dict_version;\
  1788. PyObject *__pyx_dict_cached_value;\
  1789. (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  1790. } while(0)
  1791. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
  1792. #else
  1793. #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  1794. #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  1795. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
  1796. #endif
  1797. /* TupleAndListFromArray.proto (used by fastcall) */
  1798. #if CYTHON_COMPILING_IN_CPYTHON
  1799. static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n);
  1800. #endif
  1801. #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_METH_FASTCALL
  1802. static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n);
  1803. #endif
  1804. /* IncludeStringH.proto (used by BytesEquals) */
  1805. #include <string.h>
  1806. /* BytesEquals.proto (used by UnicodeEquals) */
  1807. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
  1808. /* UnicodeEquals.proto (used by fastcall) */
  1809. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
  1810. /* fastcall.proto */
  1811. #if CYTHON_AVOID_BORROWED_REFS
  1812. #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_PySequence_ITEM(args, i)
  1813. #elif CYTHON_ASSUME_SAFE_MACROS
  1814. #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_NewRef(__Pyx_PyTuple_GET_ITEM(args, i))
  1815. #else
  1816. #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_XNewRef(PyTuple_GetItem(args, i))
  1817. #endif
  1818. #define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds)
  1819. #define __Pyx_KwValues_VARARGS(args, nargs) NULL
  1820. #define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s)
  1821. #define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw)
  1822. #if CYTHON_METH_FASTCALL
  1823. #define __Pyx_ArgRef_FASTCALL(args, i) __Pyx_NewRef(args[i])
  1824. #define __Pyx_NumKwargs_FASTCALL(kwds) __Pyx_PyTuple_GET_SIZE(kwds)
  1825. #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs))
  1826. static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s);
  1827. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
  1828. CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues);
  1829. #else
  1830. #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw)
  1831. #endif
  1832. #else
  1833. #define __Pyx_ArgRef_FASTCALL __Pyx_ArgRef_VARARGS
  1834. #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS
  1835. #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS
  1836. #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS
  1837. #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS
  1838. #endif
  1839. #define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop)
  1840. #if CYTHON_METH_FASTCALL || (CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
  1841. #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(args + start, stop - start)
  1842. #else
  1843. #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop)
  1844. #endif
  1845. /* py_dict_items.proto (used by OwnedDictNext) */
  1846. static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);
  1847. /* CallCFunction.proto (used by CallUnboundCMethod0) */
  1848. #define __Pyx_CallCFunction(cfunc, self, args)\
  1849. ((PyCFunction)(void(*)(void))(cfunc)->func)(self, args)
  1850. #define __Pyx_CallCFunctionWithKeywords(cfunc, self, args, kwargs)\
  1851. ((PyCFunctionWithKeywords)(void(*)(void))(cfunc)->func)(self, args, kwargs)
  1852. #define __Pyx_CallCFunctionFast(cfunc, self, args, nargs)\
  1853. ((__Pyx_PyCFunctionFast)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs)
  1854. #define __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, nargs, kwnames)\
  1855. ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs, kwnames)
  1856. /* PyObjectCallOneArg.proto (used by CallUnboundCMethod0) */
  1857. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  1858. /* UnpackUnboundCMethod.proto (used by CallUnboundCMethod0) */
  1859. typedef struct {
  1860. PyObject *type;
  1861. PyObject **method_name;
  1862. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && CYTHON_ATOMICS
  1863. __pyx_atomic_int_type initialized;
  1864. #endif
  1865. PyCFunction func;
  1866. PyObject *method;
  1867. int flag;
  1868. } __Pyx_CachedCFunction;
  1869. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1870. static CYTHON_INLINE int __Pyx_CachedCFunction_GetAndSetInitializing(__Pyx_CachedCFunction *cfunc) {
  1871. #if !CYTHON_ATOMICS
  1872. return 1;
  1873. #else
  1874. __pyx_nonatomic_int_type expected = 0;
  1875. if (__pyx_atomic_int_cmp_exchange(&cfunc->initialized, &expected, 1)) {
  1876. return 0;
  1877. }
  1878. return expected;
  1879. #endif
  1880. }
  1881. static CYTHON_INLINE void __Pyx_CachedCFunction_SetFinishedInitializing(__Pyx_CachedCFunction *cfunc) {
  1882. #if CYTHON_ATOMICS
  1883. __pyx_atomic_store(&cfunc->initialized, 2);
  1884. #endif
  1885. }
  1886. #else
  1887. #define __Pyx_CachedCFunction_GetAndSetInitializing(cfunc) 2
  1888. #define __Pyx_CachedCFunction_SetFinishedInitializing(cfunc)
  1889. #endif
  1890. /* CallUnboundCMethod0.proto */
  1891. CYTHON_UNUSED
  1892. static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
  1893. #if CYTHON_COMPILING_IN_CPYTHON
  1894. static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
  1895. #else
  1896. #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self)
  1897. #endif
  1898. /* py_dict_values.proto (used by OwnedDictNext) */
  1899. static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d);
  1900. /* OwnedDictNext.proto (used by ParseKeywordsImpl) */
  1901. #if CYTHON_AVOID_BORROWED_REFS
  1902. static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue);
  1903. #else
  1904. CYTHON_INLINE
  1905. static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue);
  1906. #endif
  1907. /* RaiseDoubleKeywords.proto (used by ParseKeywordsImpl) */
  1908. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  1909. /* ParseKeywordsImpl.export */
  1910. static int __Pyx_ParseKeywordsTuple(
  1911. PyObject *kwds,
  1912. PyObject * const *kwvalues,
  1913. PyObject ** const argnames[],
  1914. PyObject *kwds2,
  1915. PyObject *values[],
  1916. Py_ssize_t num_pos_args,
  1917. Py_ssize_t num_kwargs,
  1918. const char* function_name,
  1919. int ignore_unknown_kwargs
  1920. );
  1921. static int __Pyx_ParseKeywordDictToDict(
  1922. PyObject *kwds,
  1923. PyObject ** const argnames[],
  1924. PyObject *kwds2,
  1925. PyObject *values[],
  1926. Py_ssize_t num_pos_args,
  1927. const char* function_name
  1928. );
  1929. static int __Pyx_ParseKeywordDict(
  1930. PyObject *kwds,
  1931. PyObject ** const argnames[],
  1932. PyObject *values[],
  1933. Py_ssize_t num_pos_args,
  1934. Py_ssize_t num_kwargs,
  1935. const char* function_name,
  1936. int ignore_unknown_kwargs
  1937. );
  1938. /* CallUnboundCMethod2.proto */
  1939. CYTHON_UNUSED
  1940. static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
  1941. #if CYTHON_COMPILING_IN_CPYTHON
  1942. static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
  1943. #else
  1944. #define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
  1945. #endif
  1946. /* ParseKeywords.proto */
  1947. static CYTHON_INLINE int __Pyx_ParseKeywords(
  1948. PyObject *kwds, PyObject *const *kwvalues, PyObject ** const argnames[],
  1949. PyObject *kwds2, PyObject *values[],
  1950. Py_ssize_t num_pos_args, Py_ssize_t num_kwargs,
  1951. const char* function_name,
  1952. int ignore_unknown_kwargs
  1953. );
  1954. /* RaiseArgTupleInvalid.proto */
  1955. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  1956. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  1957. /* GetException.proto (used by pep479) */
  1958. #if CYTHON_FAST_THREAD_STATE
  1959. #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
  1960. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1961. #else
  1962. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
  1963. #endif
  1964. /* pep479.proto */
  1965. static void __Pyx_Generator_Replace_StopIteration(int in_async_gen);
  1966. /* GetTopmostException.proto (used by SaveResetException) */
  1967. #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
  1968. static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
  1969. #endif
  1970. /* SaveResetException.proto */
  1971. #if CYTHON_FAST_THREAD_STATE
  1972. #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
  1973. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1974. #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
  1975. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1976. #else
  1977. #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
  1978. #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
  1979. #endif
  1980. /* PyZeroDivisionError_Check.proto */
  1981. #define __Pyx_PyExc_ZeroDivisionError_Check(obj) __Pyx_TypeCheck(obj, PyExc_ZeroDivisionError)
  1982. /* IterNextPlain.proto (used by IterNext) */
  1983. static CYTHON_INLINE PyObject *__Pyx_PyIter_Next_Plain(PyObject *iterator);
  1984. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  1985. static PyObject *__Pyx_GetBuiltinNext_LimitedAPI(void);
  1986. #endif
  1987. /* IterNext.proto */
  1988. #define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
  1989. static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *);
  1990. /* ListAppend.proto */
  1991. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
  1992. static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
  1993. PyListObject* L = (PyListObject*) list;
  1994. Py_ssize_t len = Py_SIZE(list);
  1995. if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
  1996. Py_INCREF(x);
  1997. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
  1998. L->ob_item[len] = x;
  1999. #else
  2000. PyList_SET_ITEM(list, len, x);
  2001. #endif
  2002. __Pyx_SET_SIZE(list, len + 1);
  2003. return 0;
  2004. }
  2005. return PyList_Append(list, x);
  2006. }
  2007. #else
  2008. #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
  2009. #endif
  2010. /* ListCompAppend.proto */
  2011. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
  2012. static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
  2013. PyListObject* L = (PyListObject*) list;
  2014. Py_ssize_t len = Py_SIZE(list);
  2015. if (likely(L->allocated > len)) {
  2016. Py_INCREF(x);
  2017. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
  2018. L->ob_item[len] = x;
  2019. #else
  2020. PyList_SET_ITEM(list, len, x);
  2021. #endif
  2022. __Pyx_SET_SIZE(list, len + 1);
  2023. return 0;
  2024. }
  2025. return PyList_Append(list, x);
  2026. }
  2027. #else
  2028. #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
  2029. #endif
  2030. /* PyLongBinop.proto */
  2031. #if !CYTHON_COMPILING_IN_PYPY
  2032. static CYTHON_INLINE PyObject* __Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
  2033. #else
  2034. #define __Pyx_PyLong_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
  2035. (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
  2036. #endif
  2037. /* RaiseException.export */
  2038. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  2039. /* PyValueError_Check.proto */
  2040. #define __Pyx_PyExc_ValueError_Check(obj) __Pyx_TypeCheck(obj, PyExc_ValueError)
  2041. /* SetItemInt.proto */
  2042. #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  2043. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  2044. __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck, unsafe_shared) :\
  2045. (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
  2046. __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
  2047. static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
  2048. static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
  2049. int is_list, int wraparound, int boundscheck, int unsafe_shared);
  2050. /* ModInt[long].proto */
  2051. static CYTHON_INLINE long __Pyx_mod_long(long, long, int b_is_constant);
  2052. /* CheckTypeForFreelists.proto */
  2053. #if CYTHON_USE_FREELISTS
  2054. #if CYTHON_USE_TYPE_SPECS
  2055. #define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t) == (expected_tp)))
  2056. #define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS Py_TPFLAGS_IS_ABSTRACT
  2057. #else
  2058. #define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t)->tp_basicsize == (expected_size)))
  2059. #define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)
  2060. #endif
  2061. #define __PYX_CHECK_TYPE_FOR_FREELISTS(t, expected_tp, expected_size)\
  2062. (__PYX_CHECK_FINAL_TYPE_FOR_FREELISTS((t), (expected_tp), (expected_size)) &\
  2063. (int) (!__Pyx_PyType_HasFeature((t), __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS)))
  2064. #endif
  2065. /* AllocateExtensionType.proto */
  2066. static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final);
  2067. /* LimitedApiGetTypeDict.proto (used by SetItemOnTypeDict) */
  2068. #if CYTHON_COMPILING_IN_LIMITED_API
  2069. static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp);
  2070. #endif
  2071. /* SetItemOnTypeDict.proto (used by FixUpExtensionType) */
  2072. static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v);
  2073. #define __Pyx_SetItemOnTypeDict(tp, k, v) __Pyx__SetItemOnTypeDict((PyTypeObject*)tp, k, v)
  2074. /* FixUpExtensionType.proto */
  2075. static CYTHON_INLINE int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type);
  2076. /* PyObjectCallNoArg.proto (used by PyObjectCallMethod0) */
  2077. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
  2078. /* PyObjectGetMethod.proto (used by PyObjectCallMethod0) */
  2079. #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
  2080. static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
  2081. #endif
  2082. /* PyObjectCallMethod0.proto (used by PyType_Ready) */
  2083. static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
  2084. /* ValidateBasesTuple.proto (used by PyType_Ready) */
  2085. #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
  2086. static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases);
  2087. #endif
  2088. /* PyType_Ready.proto */
  2089. CYTHON_UNUSED static int __Pyx_PyType_Ready(PyTypeObject *t);
  2090. /* HasAttr.proto (used by ImportImpl) */
  2091. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  2092. #define __Pyx_HasAttr(o, n) PyObject_HasAttrWithError(o, n)
  2093. #else
  2094. static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
  2095. #endif
  2096. /* ImportImpl.export */
  2097. static PyObject *__Pyx__Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, PyObject *moddict, int level);
  2098. /* Import.proto */
  2099. static CYTHON_INLINE PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level);
  2100. /* ImportFrom.proto */
  2101. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
  2102. /* ListPack.proto */
  2103. static PyObject *__Pyx_PyList_Pack(Py_ssize_t n, ...);
  2104. /* pybytes_as_double.proto (used by pyunicode_as_double) */
  2105. static double __Pyx_SlowPyString_AsDouble(PyObject *obj);
  2106. static double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length);
  2107. static CYTHON_INLINE double __Pyx_PyBytes_AsDouble(PyObject *obj) {
  2108. char* as_c_string;
  2109. Py_ssize_t size;
  2110. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  2111. as_c_string = PyBytes_AS_STRING(obj);
  2112. size = PyBytes_GET_SIZE(obj);
  2113. #else
  2114. if (PyBytes_AsStringAndSize(obj, &as_c_string, &size) < 0) {
  2115. return (double)-1;
  2116. }
  2117. #endif
  2118. return __Pyx__PyBytes_AsDouble(obj, as_c_string, size);
  2119. }
  2120. static CYTHON_INLINE double __Pyx_PyByteArray_AsDouble(PyObject *obj) {
  2121. char* as_c_string;
  2122. Py_ssize_t size;
  2123. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  2124. as_c_string = PyByteArray_AS_STRING(obj);
  2125. size = PyByteArray_GET_SIZE(obj);
  2126. #else
  2127. as_c_string = PyByteArray_AsString(obj);
  2128. if (as_c_string == NULL) {
  2129. return (double)-1;
  2130. }
  2131. size = PyByteArray_Size(obj);
  2132. #endif
  2133. return __Pyx__PyBytes_AsDouble(obj, as_c_string, size);
  2134. }
  2135. /* pyunicode_as_double.proto */
  2136. #if !CYTHON_COMPILING_IN_PYPY && CYTHON_ASSUME_SAFE_MACROS
  2137. static const char* __Pyx__PyUnicode_AsDouble_Copy(const void* data, const int kind, char* buffer, Py_ssize_t start, Py_ssize_t end) {
  2138. int last_was_punctuation;
  2139. Py_ssize_t i;
  2140. last_was_punctuation = 1;
  2141. for (i=start; i <= end; i++) {
  2142. Py_UCS4 chr = PyUnicode_READ(kind, data, i);
  2143. int is_punctuation = (chr == '_') | (chr == '.');
  2144. *buffer = (char)chr;
  2145. buffer += (chr != '_');
  2146. if (unlikely(chr > 127)) goto parse_failure;
  2147. if (unlikely(last_was_punctuation & is_punctuation)) goto parse_failure;
  2148. last_was_punctuation = is_punctuation;
  2149. }
  2150. if (unlikely(last_was_punctuation)) goto parse_failure;
  2151. *buffer = '\0';
  2152. return buffer;
  2153. parse_failure:
  2154. return NULL;
  2155. }
  2156. static double __Pyx__PyUnicode_AsDouble_inf_nan(const void* data, int kind, Py_ssize_t start, Py_ssize_t length) {
  2157. int matches = 1;
  2158. Py_UCS4 chr;
  2159. Py_UCS4 sign = PyUnicode_READ(kind, data, start);
  2160. int is_signed = (sign == '-') | (sign == '+');
  2161. start += is_signed;
  2162. length -= is_signed;
  2163. switch (PyUnicode_READ(kind, data, start)) {
  2164. #ifdef Py_NAN
  2165. case 'n':
  2166. case 'N':
  2167. if (unlikely(length != 3)) goto parse_failure;
  2168. chr = PyUnicode_READ(kind, data, start+1);
  2169. matches &= (chr == 'a') | (chr == 'A');
  2170. chr = PyUnicode_READ(kind, data, start+2);
  2171. matches &= (chr == 'n') | (chr == 'N');
  2172. if (unlikely(!matches)) goto parse_failure;
  2173. return (sign == '-') ? -Py_NAN : Py_NAN;
  2174. #endif
  2175. case 'i':
  2176. case 'I':
  2177. if (unlikely(length < 3)) goto parse_failure;
  2178. chr = PyUnicode_READ(kind, data, start+1);
  2179. matches &= (chr == 'n') | (chr == 'N');
  2180. chr = PyUnicode_READ(kind, data, start+2);
  2181. matches &= (chr == 'f') | (chr == 'F');
  2182. if (likely(length == 3 && matches))
  2183. return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL;
  2184. if (unlikely(length != 8)) goto parse_failure;
  2185. chr = PyUnicode_READ(kind, data, start+3);
  2186. matches &= (chr == 'i') | (chr == 'I');
  2187. chr = PyUnicode_READ(kind, data, start+4);
  2188. matches &= (chr == 'n') | (chr == 'N');
  2189. chr = PyUnicode_READ(kind, data, start+5);
  2190. matches &= (chr == 'i') | (chr == 'I');
  2191. chr = PyUnicode_READ(kind, data, start+6);
  2192. matches &= (chr == 't') | (chr == 'T');
  2193. chr = PyUnicode_READ(kind, data, start+7);
  2194. matches &= (chr == 'y') | (chr == 'Y');
  2195. if (unlikely(!matches)) goto parse_failure;
  2196. return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL;
  2197. case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
  2198. break;
  2199. default:
  2200. goto parse_failure;
  2201. }
  2202. return 0.0;
  2203. parse_failure:
  2204. return -1.0;
  2205. }
  2206. static double __Pyx_PyUnicode_AsDouble_WithSpaces(PyObject *obj) {
  2207. double value;
  2208. const char *last;
  2209. char *end;
  2210. Py_ssize_t start, length = PyUnicode_GET_LENGTH(obj);
  2211. const int kind = PyUnicode_KIND(obj);
  2212. const void* data = PyUnicode_DATA(obj);
  2213. start = 0;
  2214. while (Py_UNICODE_ISSPACE(PyUnicode_READ(kind, data, start)))
  2215. start++;
  2216. while (start < length - 1 && Py_UNICODE_ISSPACE(PyUnicode_READ(kind, data, length - 1)))
  2217. length--;
  2218. length -= start;
  2219. if (unlikely(length <= 0)) goto fallback;
  2220. value = __Pyx__PyUnicode_AsDouble_inf_nan(data, kind, start, length);
  2221. if (unlikely(value == -1.0)) goto fallback;
  2222. if (value != 0.0) return value;
  2223. if (length < 40) {
  2224. char number[40];
  2225. last = __Pyx__PyUnicode_AsDouble_Copy(data, kind, number, start, start + length);
  2226. if (unlikely(!last)) goto fallback;
  2227. value = PyOS_string_to_double(number, &end, NULL);
  2228. } else {
  2229. char *number = (char*) PyMem_Malloc((length + 1) * sizeof(char));
  2230. if (unlikely(!number)) goto fallback;
  2231. last = __Pyx__PyUnicode_AsDouble_Copy(data, kind, number, start, start + length);
  2232. if (unlikely(!last)) {
  2233. PyMem_Free(number);
  2234. goto fallback;
  2235. }
  2236. value = PyOS_string_to_double(number, &end, NULL);
  2237. PyMem_Free(number);
  2238. }
  2239. if (likely(end == last) || (value == (double)-1 && PyErr_Occurred())) {
  2240. return value;
  2241. }
  2242. fallback:
  2243. return __Pyx_SlowPyString_AsDouble(obj);
  2244. }
  2245. #endif
  2246. static CYTHON_INLINE double __Pyx_PyUnicode_AsDouble(PyObject *obj) {
  2247. #if !CYTHON_COMPILING_IN_PYPY && CYTHON_ASSUME_SAFE_MACROS
  2248. if (unlikely(__Pyx_PyUnicode_READY(obj) == -1))
  2249. return (double)-1;
  2250. if (likely(PyUnicode_IS_ASCII(obj))) {
  2251. const char *s;
  2252. Py_ssize_t length;
  2253. s = PyUnicode_AsUTF8AndSize(obj, &length);
  2254. return __Pyx__PyBytes_AsDouble(obj, s, length);
  2255. }
  2256. return __Pyx_PyUnicode_AsDouble_WithSpaces(obj);
  2257. #else
  2258. return __Pyx_SlowPyString_AsDouble(obj);
  2259. #endif
  2260. }
  2261. /* FloatExceptionCheck.proto */
  2262. #define __PYX_CHECK_FLOAT_EXCEPTION(value, error_value)\
  2263. ((error_value) == (error_value) ?\
  2264. (value) == (error_value) :\
  2265. (value) != (value))
  2266. /* dict_setdefault.proto (used by FetchCommonType) */
  2267. static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value);
  2268. /* AddModuleRef.proto (used by FetchSharedCythonModule) */
  2269. #if ((CYTHON_COMPILING_IN_CPYTHON_FREETHREADING ) ||\
  2270. __PYX_LIMITED_VERSION_HEX < 0x030d0000)
  2271. static PyObject *__Pyx_PyImport_AddModuleRef(const char *name);
  2272. #else
  2273. #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
  2274. #endif
  2275. /* FetchSharedCythonModule.proto (used by FetchCommonType) */
  2276. static PyObject *__Pyx_FetchSharedCythonABIModule(void);
  2277. /* FetchCommonType.proto (used by CommonTypesMetaclass) */
  2278. static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases);
  2279. /* CommonTypesMetaclass.proto (used by CythonFunctionShared) */
  2280. static int __pyx_CommonTypesMetaclass_init(PyObject *module);
  2281. #define __Pyx_CommonTypesMetaclass_USED
  2282. /* CallTypeTraverse.proto (used by CythonFunctionShared) */
  2283. #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000)
  2284. #define __Pyx_call_type_traverse(o, always_call, visit, arg) 0
  2285. #else
  2286. static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg);
  2287. #endif
  2288. /* PyMethodNew.proto (used by CythonFunctionShared) */
  2289. static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ);
  2290. /* PyVectorcallFastCallDict.proto (used by CythonFunctionShared) */
  2291. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  2292. static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw);
  2293. #endif
  2294. /* CythonFunctionShared.proto (used by CythonFunction) */
  2295. #define __Pyx_CyFunction_USED
  2296. #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
  2297. #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
  2298. #define __Pyx_CYFUNCTION_CCLASS 0x04
  2299. #define __Pyx_CYFUNCTION_COROUTINE 0x08
  2300. #define __Pyx_CyFunction_GetClosure(f)\
  2301. (((__pyx_CyFunctionObject *) (f))->func_closure)
  2302. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  2303. #define __Pyx_CyFunction_GetClassObj(f)\
  2304. (((__pyx_CyFunctionObject *) (f))->func_classobj)
  2305. #else
  2306. #define __Pyx_CyFunction_GetClassObj(f)\
  2307. ((PyObject*) ((PyCMethodObject *) (f))->mm_class)
  2308. #endif
  2309. #define __Pyx_CyFunction_SetClassObj(f, classobj)\
  2310. __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj))
  2311. #define __Pyx_CyFunction_Defaults(type, f)\
  2312. ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
  2313. #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
  2314. ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
  2315. typedef struct {
  2316. #if CYTHON_COMPILING_IN_LIMITED_API
  2317. PyObject_HEAD
  2318. PyObject *func;
  2319. #elif PY_VERSION_HEX < 0x030900B1
  2320. PyCFunctionObject func;
  2321. #else
  2322. PyCMethodObject func;
  2323. #endif
  2324. #if CYTHON_COMPILING_IN_LIMITED_API && CYTHON_METH_FASTCALL
  2325. __pyx_vectorcallfunc func_vectorcall;
  2326. #endif
  2327. #if CYTHON_COMPILING_IN_LIMITED_API
  2328. PyObject *func_weakreflist;
  2329. #endif
  2330. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  2331. PyObject *func_dict;
  2332. #endif
  2333. PyObject *func_name;
  2334. PyObject *func_qualname;
  2335. PyObject *func_doc;
  2336. PyObject *func_globals;
  2337. PyObject *func_code;
  2338. PyObject *func_closure;
  2339. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  2340. PyObject *func_classobj;
  2341. #endif
  2342. PyObject *defaults;
  2343. int flags;
  2344. PyObject *defaults_tuple;
  2345. PyObject *defaults_kwdict;
  2346. PyObject *(*defaults_getter)(PyObject *);
  2347. PyObject *func_annotations;
  2348. PyObject *func_is_coroutine;
  2349. } __pyx_CyFunctionObject;
  2350. #undef __Pyx_CyOrPyCFunction_Check
  2351. #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, __pyx_mstate_global->__pyx_CyFunctionType)
  2352. #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, __pyx_mstate_global->__pyx_CyFunctionType, &PyCFunction_Type)
  2353. #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_CyFunctionType)
  2354. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void));
  2355. #undef __Pyx_IsSameCFunction
  2356. #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc)
  2357. static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
  2358. int flags, PyObject* qualname,
  2359. PyObject *closure,
  2360. PyObject *module, PyObject *globals,
  2361. PyObject* code);
  2362. static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj);
  2363. static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func,
  2364. PyTypeObject *defaults_type);
  2365. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
  2366. PyObject *tuple);
  2367. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
  2368. PyObject *dict);
  2369. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
  2370. PyObject *dict);
  2371. static int __pyx_CyFunction_init(PyObject *module);
  2372. #if CYTHON_METH_FASTCALL
  2373. static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2374. static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2375. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2376. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2377. #if CYTHON_COMPILING_IN_LIMITED_API
  2378. #define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall)
  2379. #else
  2380. #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall)
  2381. #endif
  2382. #endif
  2383. /* CythonFunction.proto */
  2384. static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
  2385. int flags, PyObject* qualname,
  2386. PyObject *closure,
  2387. PyObject *module, PyObject *globals,
  2388. PyObject* code);
  2389. /* CLineInTraceback.proto (used by AddTraceback) */
  2390. #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  2391. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  2392. #else
  2393. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  2394. #endif
  2395. /* CodeObjectCache.proto (used by AddTraceback) */
  2396. #if CYTHON_COMPILING_IN_LIMITED_API
  2397. typedef PyObject __Pyx_CachedCodeObjectType;
  2398. #else
  2399. typedef PyCodeObject __Pyx_CachedCodeObjectType;
  2400. #endif
  2401. typedef struct {
  2402. __Pyx_CachedCodeObjectType* code_object;
  2403. int code_line;
  2404. } __Pyx_CodeObjectCacheEntry;
  2405. struct __Pyx_CodeObjectCache {
  2406. int count;
  2407. int max_count;
  2408. __Pyx_CodeObjectCacheEntry* entries;
  2409. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  2410. __pyx_atomic_int_type accessor_count;
  2411. #endif
  2412. };
  2413. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  2414. static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line);
  2415. static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object);
  2416. /* AddTraceback.proto */
  2417. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  2418. int py_line, const char *filename);
  2419. /* RealImag.proto */
  2420. #if CYTHON_CCOMPLEX
  2421. #ifdef __cplusplus
  2422. #define __Pyx_CREAL(z) ((z).real())
  2423. #define __Pyx_CIMAG(z) ((z).imag())
  2424. #else
  2425. #define __Pyx_CREAL(z) (__real__(z))
  2426. #define __Pyx_CIMAG(z) (__imag__(z))
  2427. #endif
  2428. #else
  2429. #define __Pyx_CREAL(z) ((z).real)
  2430. #define __Pyx_CIMAG(z) ((z).imag)
  2431. #endif
  2432. #if defined(__cplusplus) && CYTHON_CCOMPLEX\
  2433. && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
  2434. #define __Pyx_SET_CREAL(z,x) ((z).real(x))
  2435. #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
  2436. #else
  2437. #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
  2438. #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
  2439. #endif
  2440. /* Arithmetic.proto */
  2441. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  2442. #define __Pyx_c_eq_double(a, b) ((a)==(b))
  2443. #define __Pyx_c_sum_double(a, b) ((a)+(b))
  2444. #define __Pyx_c_diff_double(a, b) ((a)-(b))
  2445. #define __Pyx_c_prod_double(a, b) ((a)*(b))
  2446. #define __Pyx_c_quot_double(a, b) ((a)/(b))
  2447. #define __Pyx_c_neg_double(a) (-(a))
  2448. #ifdef __cplusplus
  2449. #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
  2450. #define __Pyx_c_conj_double(z) (::std::conj(z))
  2451. #if 1
  2452. #define __Pyx_c_abs_double(z) (::std::abs(z))
  2453. #define __Pyx_c_pow_double(a, b) (::std::pow(a, b))
  2454. #endif
  2455. #else
  2456. #define __Pyx_c_is_zero_double(z) ((z)==0)
  2457. #define __Pyx_c_conj_double(z) (conj(z))
  2458. #if 1
  2459. #define __Pyx_c_abs_double(z) (cabs(z))
  2460. #define __Pyx_c_pow_double(a, b) (cpow(a, b))
  2461. #endif
  2462. #endif
  2463. #else
  2464. static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2465. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2466. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2467. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2468. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2469. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
  2470. static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
  2471. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
  2472. #if 1
  2473. static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
  2474. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2475. #endif
  2476. #endif
  2477. /* FromPy.proto */
  2478. static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject*);
  2479. /* GCCDiagnostics.proto */
  2480. #if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
  2481. #define __Pyx_HAS_GCC_DIAGNOSTIC
  2482. #endif
  2483. /* ToPy.proto */
  2484. #define __pyx_PyComplex_FromComplex(z)\
  2485. PyComplex_FromDoubles((double)__Pyx_CREAL(z),\
  2486. (double)__Pyx_CIMAG(z))
  2487. /* CIntFromPy.proto */
  2488. static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *);
  2489. /* PyObjectVectorCallKwBuilder.proto (used by CIntToPy) */
  2490. CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n);
  2491. #if CYTHON_VECTORCALL
  2492. #if PY_VERSION_HEX >= 0x03090000
  2493. #define __Pyx_Object_Vectorcall_CallFromBuilder PyObject_Vectorcall
  2494. #else
  2495. #define __Pyx_Object_Vectorcall_CallFromBuilder _PyObject_Vectorcall
  2496. #endif
  2497. #define __Pyx_MakeVectorcallBuilderKwds(n) PyTuple_New(n)
  2498. static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n);
  2499. static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n);
  2500. #else
  2501. #define __Pyx_Object_Vectorcall_CallFromBuilder __Pyx_PyObject_FastCallDict
  2502. #define __Pyx_MakeVectorcallBuilderKwds(n) __Pyx_PyDict_NewPresized(n)
  2503. #define __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n) PyDict_SetItem(builder, key, value)
  2504. #define __Pyx_VectorcallBuilder_AddArgStr(key, value, builder, args, n) PyDict_SetItemString(builder, key, value)
  2505. #endif
  2506. /* CIntToPy.proto */
  2507. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value);
  2508. /* CIntToPy.proto */
  2509. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_int(int value);
  2510. /* FormatTypeName.proto */
  2511. #if CYTHON_COMPILING_IN_LIMITED_API
  2512. typedef PyObject *__Pyx_TypeName;
  2513. #define __Pyx_FMT_TYPENAME "%U"
  2514. #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj)
  2515. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  2516. #define __Pyx_PyType_GetFullyQualifiedName PyType_GetFullyQualifiedName
  2517. #else
  2518. static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp);
  2519. #endif
  2520. #else // !LIMITED_API
  2521. typedef const char *__Pyx_TypeName;
  2522. #define __Pyx_FMT_TYPENAME "%.200s"
  2523. #define __Pyx_PyType_GetFullyQualifiedName(tp) ((tp)->tp_name)
  2524. #define __Pyx_DECREF_TypeName(obj)
  2525. #endif
  2526. /* CIntFromPy.proto */
  2527. static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *);
  2528. /* FastTypeChecks.proto */
  2529. #if CYTHON_COMPILING_IN_CPYTHON
  2530. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  2531. #define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2)
  2532. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  2533. static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b);
  2534. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  2535. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  2536. #else
  2537. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  2538. #define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2))
  2539. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  2540. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2) {
  2541. return PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2);
  2542. }
  2543. #endif
  2544. #define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2)
  2545. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  2546. #ifdef PyExceptionInstance_Check
  2547. #define __Pyx_PyBaseException_Check(obj) PyExceptionInstance_Check(obj)
  2548. #else
  2549. #define __Pyx_PyBaseException_Check(obj) __Pyx_TypeCheck(obj, PyExc_BaseException)
  2550. #endif
  2551. /* GetRuntimeVersion.proto */
  2552. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  2553. static unsigned long __Pyx_cached_runtime_version = 0;
  2554. static void __Pyx_init_runtime_version(void);
  2555. #else
  2556. #define __Pyx_init_runtime_version()
  2557. #endif
  2558. static unsigned long __Pyx_get_runtime_version(void);
  2559. /* SwapException.proto (used by CoroutineBase) */
  2560. #if CYTHON_FAST_THREAD_STATE
  2561. #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
  2562. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  2563. #else
  2564. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
  2565. #endif
  2566. /* PyObjectCall2Args.proto (used by PyObjectCallMethod1) */
  2567. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
  2568. /* PyObjectCallMethod1.proto (used by CoroutineBase) */
  2569. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
  2570. /* ReturnWithStopIteration.proto (used by CoroutineBase) */
  2571. static CYTHON_INLINE void __Pyx_ReturnWithStopIteration(PyObject* value, int async, int iternext);
  2572. /* CoroutineBase.proto (used by Generator) */
  2573. struct __pyx_CoroutineObject;
  2574. typedef PyObject *(*__pyx_coroutine_body_t)(struct __pyx_CoroutineObject *, PyThreadState *, PyObject *);
  2575. #if CYTHON_USE_EXC_INFO_STACK
  2576. #define __Pyx_ExcInfoStruct _PyErr_StackItem
  2577. #else
  2578. typedef struct {
  2579. PyObject *exc_type;
  2580. PyObject *exc_value;
  2581. PyObject *exc_traceback;
  2582. } __Pyx_ExcInfoStruct;
  2583. #endif
  2584. typedef struct __pyx_CoroutineObject {
  2585. PyObject_HEAD
  2586. __pyx_coroutine_body_t body;
  2587. PyObject *closure;
  2588. __Pyx_ExcInfoStruct gi_exc_state;
  2589. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  2590. PyObject *gi_weakreflist;
  2591. #endif
  2592. PyObject *classobj;
  2593. PyObject *yieldfrom;
  2594. __Pyx_pyiter_sendfunc yieldfrom_am_send;
  2595. PyObject *gi_name;
  2596. PyObject *gi_qualname;
  2597. PyObject *gi_modulename;
  2598. PyObject *gi_code;
  2599. PyObject *gi_frame;
  2600. #if CYTHON_USE_SYS_MONITORING && (CYTHON_PROFILE || CYTHON_TRACE)
  2601. PyMonitoringState __pyx_pymonitoring_state[__Pyx_MonitoringEventTypes_CyGen_count];
  2602. uint64_t __pyx_pymonitoring_version;
  2603. #endif
  2604. int resume_label;
  2605. char is_running;
  2606. } __pyx_CoroutineObject;
  2607. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  2608. PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  2609. PyObject *name, PyObject *qualname, PyObject *module_name);
  2610. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  2611. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  2612. PyObject *name, PyObject *qualname, PyObject *module_name);
  2613. static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
  2614. static int __Pyx_Coroutine_clear(PyObject *self);
  2615. static __Pyx_PySendResult __Pyx_Coroutine_AmSend(PyObject *self, PyObject *value, PyObject **retval);
  2616. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
  2617. static __Pyx_PySendResult __Pyx_Coroutine_Close(PyObject *self, PyObject **retval);
  2618. static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
  2619. #if CYTHON_USE_EXC_INFO_STACK
  2620. #define __Pyx_Coroutine_SwapException(self)
  2621. #define __Pyx_Coroutine_ResetAndClearException(self) __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
  2622. #else
  2623. #define __Pyx_Coroutine_SwapException(self) {\
  2624. __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
  2625. __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
  2626. }
  2627. #define __Pyx_Coroutine_ResetAndClearException(self) {\
  2628. __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
  2629. (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
  2630. }
  2631. #endif
  2632. #if CYTHON_FAST_THREAD_STATE
  2633. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  2634. __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
  2635. #else
  2636. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  2637. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
  2638. #endif
  2639. static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
  2640. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);
  2641. static char __Pyx_Coroutine_test_and_set_is_running(__pyx_CoroutineObject *gen);
  2642. static void __Pyx_Coroutine_unset_is_running(__pyx_CoroutineObject *gen);
  2643. static char __Pyx_Coroutine_get_is_running(__pyx_CoroutineObject *gen);
  2644. static PyObject *__Pyx_Coroutine_get_is_running_getter(PyObject *gen, void *closure);
  2645. #if __PYX_HAS_PY_AM_SEND == 2
  2646. static void __Pyx_SetBackportTypeAmSend(PyTypeObject *type, __Pyx_PyAsyncMethodsStruct *static_amsend_methods, __Pyx_pyiter_sendfunc am_send);
  2647. #endif
  2648. static PyObject *__Pyx_Coroutine_fail_reduce_ex(PyObject *self, PyObject *arg);
  2649. /* Generator.proto */
  2650. #define __Pyx_Generator_USED
  2651. #define __Pyx_Generator_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_GeneratorType)
  2652. #define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
  2653. __Pyx__Coroutine_New(__pyx_mstate_global->__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
  2654. static PyObject *__Pyx_Generator_Next(PyObject *self);
  2655. static int __pyx_Generator_init(PyObject *module);
  2656. static CYTHON_INLINE PyObject *__Pyx_Generator_GetInlinedResult(PyObject *self);
  2657. /* CheckBinaryVersion.proto */
  2658. static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer);
  2659. /* DecompressString.proto */
  2660. static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo);
  2661. /* MultiPhaseInitModuleState.proto */
  2662. #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
  2663. static PyObject *__Pyx_State_FindModule(void*);
  2664. static int __Pyx_State_AddModule(PyObject* module, void*);
  2665. static int __Pyx_State_RemoveModule(void*);
  2666. #elif CYTHON_USE_MODULE_STATE
  2667. #define __Pyx_State_FindModule PyState_FindModule
  2668. #define __Pyx_State_AddModule PyState_AddModule
  2669. #define __Pyx_State_RemoveModule PyState_RemoveModule
  2670. #endif
  2671. /* #### Code section: module_declarations ### */
  2672. /* CythonABIVersion.proto */
  2673. #if CYTHON_COMPILING_IN_LIMITED_API
  2674. #if CYTHON_METH_FASTCALL
  2675. #define __PYX_FASTCALL_ABI_SUFFIX "_fastcall"
  2676. #else
  2677. #define __PYX_FASTCALL_ABI_SUFFIX
  2678. #endif
  2679. #define __PYX_LIMITED_ABI_SUFFIX "limited" __PYX_FASTCALL_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX
  2680. #else
  2681. #define __PYX_LIMITED_ABI_SUFFIX
  2682. #endif
  2683. #if __PYX_HAS_PY_AM_SEND == 1
  2684. #define __PYX_AM_SEND_ABI_SUFFIX
  2685. #elif __PYX_HAS_PY_AM_SEND == 2
  2686. #define __PYX_AM_SEND_ABI_SUFFIX "amsendbackport"
  2687. #else
  2688. #define __PYX_AM_SEND_ABI_SUFFIX "noamsend"
  2689. #endif
  2690. #ifndef __PYX_MONITORING_ABI_SUFFIX
  2691. #define __PYX_MONITORING_ABI_SUFFIX
  2692. #endif
  2693. #if CYTHON_USE_TP_FINALIZE
  2694. #define __PYX_TP_FINALIZE_ABI_SUFFIX
  2695. #else
  2696. #define __PYX_TP_FINALIZE_ABI_SUFFIX "nofinalize"
  2697. #endif
  2698. #if CYTHON_USE_FREELISTS || !defined(__Pyx_AsyncGen_USED)
  2699. #define __PYX_FREELISTS_ABI_SUFFIX
  2700. #else
  2701. #define __PYX_FREELISTS_ABI_SUFFIX "nofreelists"
  2702. #endif
  2703. #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
  2704. #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI
  2705. #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."
  2706. /* Module declarations from "cython" */
  2707. /* Module declarations from "fontTools.cu2qu.cu2qu" */
  2708. static CYTHON_INLINE double __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_t_double_complex, __pyx_t_double_complex); /*proto*/
  2709. static PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu__complex_div_by_real(__pyx_t_double_complex, double); /*proto*/
  2710. 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*/
  2711. 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*/
  2712. 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*/
  2713. 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*/
  2714. 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*/
  2715. 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*/
  2716. 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*/
  2717. 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*/
  2718. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_quadratic(PyObject *, double); /*proto*/
  2719. static PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(PyObject *, int, double, int); /*proto*/
  2720. /* #### Code section: typeinfo ### */
  2721. /* #### Code section: before_global_var ### */
  2722. #define __Pyx_MODULE_NAME "fontTools.cu2qu.cu2qu"
  2723. extern int __pyx_module_is_main_fontTools__cu2qu__cu2qu;
  2724. int __pyx_module_is_main_fontTools__cu2qu__cu2qu = 0;
  2725. /* Implementation of "fontTools.cu2qu.cu2qu" */
  2726. /* #### Code section: global_var ### */
  2727. /* #### Code section: string_decls ### */
  2728. /* #### Code section: decls ### */
  2729. 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 */
  2730. 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 */
  2731. 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 */
  2732. static PyObject *__pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  2733. /* #### Code section: late_includes ### */
  2734. /* #### Code section: module_state ### */
  2735. /* SmallCodeConfig */
  2736. #ifndef CYTHON_SMALL_CODE
  2737. #if defined(__clang__)
  2738. #define CYTHON_SMALL_CODE
  2739. #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  2740. #define CYTHON_SMALL_CODE __attribute__((cold))
  2741. #else
  2742. #define CYTHON_SMALL_CODE
  2743. #endif
  2744. #endif
  2745. typedef struct {
  2746. PyObject *__pyx_d;
  2747. PyObject *__pyx_b;
  2748. PyObject *__pyx_cython_runtime;
  2749. PyObject *__pyx_empty_tuple;
  2750. PyObject *__pyx_empty_bytes;
  2751. PyObject *__pyx_empty_unicode;
  2752. PyObject *__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen;
  2753. PyTypeObject *__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen;
  2754. __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items;
  2755. __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop;
  2756. __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values;
  2757. PyObject *__pyx_codeobj_tab[3];
  2758. PyObject *__pyx_string_tab[81];
  2759. PyObject *__pyx_number_tab[6];
  2760. /* #### Code section: module_state_contents ### */
  2761. /* IterNextPlain.module_state_decls */
  2762. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  2763. PyObject *__Pyx_GetBuiltinNext_LimitedAPI_cache;
  2764. #endif
  2765. #if CYTHON_USE_FREELISTS
  2766. 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];
  2767. int __pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen;
  2768. #endif
  2769. /* CommonTypesMetaclass.module_state_decls */
  2770. PyTypeObject *__pyx_CommonTypesMetaclassType;
  2771. /* CachedMethodType.module_state_decls */
  2772. #if CYTHON_COMPILING_IN_LIMITED_API
  2773. PyObject *__Pyx_CachedMethodType;
  2774. #endif
  2775. /* CythonFunctionShared.module_state_decls */
  2776. PyTypeObject *__pyx_CyFunctionType;
  2777. /* CodeObjectCache.module_state_decls */
  2778. struct __Pyx_CodeObjectCache __pyx_code_cache;
  2779. /* Generator.module_state_decls */
  2780. PyTypeObject *__pyx_GeneratorType;
  2781. /* #### Code section: module_state_end ### */
  2782. } __pyx_mstatetype;
  2783. #if CYTHON_USE_MODULE_STATE
  2784. #ifdef __cplusplus
  2785. namespace {
  2786. extern struct PyModuleDef __pyx_moduledef;
  2787. } /* anonymous namespace */
  2788. #else
  2789. static struct PyModuleDef __pyx_moduledef;
  2790. #endif
  2791. #define __pyx_mstate_global (__Pyx_PyModule_GetState(__Pyx_State_FindModule(&__pyx_moduledef)))
  2792. #define __pyx_m (__Pyx_State_FindModule(&__pyx_moduledef))
  2793. #else
  2794. static __pyx_mstatetype __pyx_mstate_global_static =
  2795. #ifdef __cplusplus
  2796. {};
  2797. #else
  2798. {0};
  2799. #endif
  2800. static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_static;
  2801. #endif
  2802. /* #### Code section: constant_name_defines ### */
  2803. #define __pyx_kp_u_ __pyx_string_tab[0]
  2804. #define __pyx_kp_u_Lib_fontTools_cu2qu_cu2qu_py __pyx_string_tab[1]
  2805. #define __pyx_kp_u_Return_quadratic_Bezier_splines __pyx_string_tab[2]
  2806. #define __pyx_kp_u__2 __pyx_string_tab[3]
  2807. #define __pyx_kp_u_curves_to_quadratic_line_505 __pyx_string_tab[4]
  2808. #define __pyx_kp_u_disable __pyx_string_tab[5]
  2809. #define __pyx_kp_u_enable __pyx_string_tab[6]
  2810. #define __pyx_kp_u_fontTools_cu2qu_errors __pyx_string_tab[7]
  2811. #define __pyx_kp_u_gc __pyx_string_tab[8]
  2812. #define __pyx_kp_u_isenabled __pyx_string_tab[9]
  2813. #define __pyx_kp_u_max_errors_must_match_the_number __pyx_string_tab[10]
  2814. #define __pyx_n_u_ApproxNotFoundError __pyx_string_tab[11]
  2815. #define __pyx_n_u_COMPILED __pyx_string_tab[12]
  2816. #define __pyx_n_u_Cu2QuError __pyx_string_tab[13]
  2817. #define __pyx_n_u_Error __pyx_string_tab[14]
  2818. #define __pyx_n_u_MAX_N __pyx_string_tab[15]
  2819. #define __pyx_n_u_NAN __pyx_string_tab[16]
  2820. #define __pyx_n_u_NaN __pyx_string_tab[17]
  2821. #define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[18]
  2822. #define __pyx_n_u_a __pyx_string_tab[19]
  2823. #define __pyx_n_u_a1 __pyx_string_tab[20]
  2824. #define __pyx_n_u_all __pyx_string_tab[21]
  2825. #define __pyx_n_u_all_quadratic __pyx_string_tab[22]
  2826. #define __pyx_n_u_asyncio_coroutines __pyx_string_tab[23]
  2827. #define __pyx_n_u_b __pyx_string_tab[24]
  2828. #define __pyx_n_u_b1 __pyx_string_tab[25]
  2829. #define __pyx_n_u_c __pyx_string_tab[26]
  2830. #define __pyx_n_u_c1 __pyx_string_tab[27]
  2831. #define __pyx_n_u_cline_in_traceback __pyx_string_tab[28]
  2832. #define __pyx_n_u_close __pyx_string_tab[29]
  2833. #define __pyx_n_u_curve __pyx_string_tab[30]
  2834. #define __pyx_n_u_curve_to_quadratic __pyx_string_tab[31]
  2835. #define __pyx_n_u_curves __pyx_string_tab[32]
  2836. #define __pyx_n_u_curves_to_quadratic __pyx_string_tab[33]
  2837. #define __pyx_n_u_d __pyx_string_tab[34]
  2838. #define __pyx_n_u_d1 __pyx_string_tab[35]
  2839. #define __pyx_n_u_delta_2 __pyx_string_tab[36]
  2840. #define __pyx_n_u_delta_3 __pyx_string_tab[37]
  2841. #define __pyx_n_u_dt __pyx_string_tab[38]
  2842. #define __pyx_n_u_errors __pyx_string_tab[39]
  2843. #define __pyx_n_u_fontTools_cu2qu_cu2qu __pyx_string_tab[40]
  2844. #define __pyx_n_u_func __pyx_string_tab[41]
  2845. #define __pyx_n_u_i __pyx_string_tab[42]
  2846. #define __pyx_n_u_imag __pyx_string_tab[43]
  2847. #define __pyx_n_u_is_coroutine __pyx_string_tab[44]
  2848. #define __pyx_n_u_isnan __pyx_string_tab[45]
  2849. #define __pyx_n_u_items __pyx_string_tab[46]
  2850. #define __pyx_n_u_l __pyx_string_tab[47]
  2851. #define __pyx_n_u_last_i __pyx_string_tab[48]
  2852. #define __pyx_n_u_main __pyx_string_tab[49]
  2853. #define __pyx_n_u_math __pyx_string_tab[50]
  2854. #define __pyx_n_u_max_err __pyx_string_tab[51]
  2855. #define __pyx_n_u_max_errors __pyx_string_tab[52]
  2856. #define __pyx_n_u_module __pyx_string_tab[53]
  2857. #define __pyx_n_u_n __pyx_string_tab[54]
  2858. #define __pyx_n_u_name __pyx_string_tab[55]
  2859. #define __pyx_n_u_next __pyx_string_tab[56]
  2860. #define __pyx_n_u_p __pyx_string_tab[57]
  2861. #define __pyx_n_u_p0 __pyx_string_tab[58]
  2862. #define __pyx_n_u_p1 __pyx_string_tab[59]
  2863. #define __pyx_n_u_p2 __pyx_string_tab[60]
  2864. #define __pyx_n_u_p3 __pyx_string_tab[61]
  2865. #define __pyx_n_u_pop __pyx_string_tab[62]
  2866. #define __pyx_n_u_qualname __pyx_string_tab[63]
  2867. #define __pyx_n_u_real __pyx_string_tab[64]
  2868. #define __pyx_n_u_s __pyx_string_tab[65]
  2869. #define __pyx_n_u_send __pyx_string_tab[66]
  2870. #define __pyx_n_u_set_name __pyx_string_tab[67]
  2871. #define __pyx_n_u_setdefault __pyx_string_tab[68]
  2872. #define __pyx_n_u_spline __pyx_string_tab[69]
  2873. #define __pyx_n_u_splines __pyx_string_tab[70]
  2874. #define __pyx_n_u_split_cubic_into_n_gen __pyx_string_tab[71]
  2875. #define __pyx_n_u_t1 __pyx_string_tab[72]
  2876. #define __pyx_n_u_t1_2 __pyx_string_tab[73]
  2877. #define __pyx_n_u_test __pyx_string_tab[74]
  2878. #define __pyx_n_u_throw __pyx_string_tab[75]
  2879. #define __pyx_n_u_value __pyx_string_tab[76]
  2880. #define __pyx_n_u_values __pyx_string_tab[77]
  2881. #define __pyx_kp_b_iso88591_AWBc_U_U_3fBa_AWCy_7_2QgQgT_a_Q __pyx_string_tab[78]
  2882. #define __pyx_kp_b_iso88591_L_Qawb_4uG4y_s_s_Qa_j_t1_q_1A_a __pyx_string_tab[79]
  2883. #define __pyx_kp_b_iso88591__3 __pyx_string_tab[80]
  2884. #define __pyx_int_1 __pyx_number_tab[0]
  2885. #define __pyx_int_2 __pyx_number_tab[1]
  2886. #define __pyx_int_3 __pyx_number_tab[2]
  2887. #define __pyx_int_4 __pyx_number_tab[3]
  2888. #define __pyx_int_6 __pyx_number_tab[4]
  2889. #define __pyx_int_100 __pyx_number_tab[5]
  2890. /* #### Code section: module_state_clear ### */
  2891. #if CYTHON_USE_MODULE_STATE
  2892. static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) {
  2893. __pyx_mstatetype *clear_module_state = __Pyx_PyModule_GetState(m);
  2894. if (!clear_module_state) return 0;
  2895. Py_CLEAR(clear_module_state->__pyx_d);
  2896. Py_CLEAR(clear_module_state->__pyx_b);
  2897. Py_CLEAR(clear_module_state->__pyx_cython_runtime);
  2898. Py_CLEAR(clear_module_state->__pyx_empty_tuple);
  2899. Py_CLEAR(clear_module_state->__pyx_empty_bytes);
  2900. Py_CLEAR(clear_module_state->__pyx_empty_unicode);
  2901. #if CYTHON_PEP489_MULTI_PHASE_INIT
  2902. __Pyx_State_RemoveModule(NULL);
  2903. #endif
  2904. Py_CLEAR(clear_module_state->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen);
  2905. Py_CLEAR(clear_module_state->__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen);
  2906. for (int i=0; i<3; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); }
  2907. for (int i=0; i<81; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); }
  2908. for (int i=0; i<6; ++i) { Py_CLEAR(clear_module_state->__pyx_number_tab[i]); }
  2909. /* #### Code section: module_state_clear_contents ### */
  2910. /* CommonTypesMetaclass.module_state_clear */
  2911. Py_CLEAR(clear_module_state->__pyx_CommonTypesMetaclassType);
  2912. /* CythonFunctionShared.module_state_clear */
  2913. Py_CLEAR(clear_module_state->__pyx_CyFunctionType);
  2914. /* Generator.module_state_clear */
  2915. Py_CLEAR(clear_module_state->__pyx_GeneratorType);
  2916. /* #### Code section: module_state_clear_end ### */
  2917. return 0;
  2918. }
  2919. #endif
  2920. /* #### Code section: module_state_traverse ### */
  2921. #if CYTHON_USE_MODULE_STATE
  2922. static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) {
  2923. __pyx_mstatetype *traverse_module_state = __Pyx_PyModule_GetState(m);
  2924. if (!traverse_module_state) return 0;
  2925. Py_VISIT(traverse_module_state->__pyx_d);
  2926. Py_VISIT(traverse_module_state->__pyx_b);
  2927. Py_VISIT(traverse_module_state->__pyx_cython_runtime);
  2928. __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_tuple);
  2929. __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_bytes);
  2930. __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_unicode);
  2931. Py_VISIT(traverse_module_state->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen);
  2932. Py_VISIT(traverse_module_state->__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen);
  2933. for (int i=0; i<3; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); }
  2934. for (int i=0; i<81; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); }
  2935. for (int i=0; i<6; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_number_tab[i]); }
  2936. /* #### Code section: module_state_traverse_contents ### */
  2937. /* CommonTypesMetaclass.module_state_traverse */
  2938. Py_VISIT(traverse_module_state->__pyx_CommonTypesMetaclassType);
  2939. /* CythonFunctionShared.module_state_traverse */
  2940. Py_VISIT(traverse_module_state->__pyx_CyFunctionType);
  2941. /* Generator.module_state_traverse */
  2942. Py_VISIT(traverse_module_state->__pyx_GeneratorType);
  2943. /* #### Code section: module_state_traverse_end ### */
  2944. return 0;
  2945. }
  2946. #endif
  2947. /* #### Code section: module_code ### */
  2948. /* "fontTools/cu2qu/cu2qu.py":37
  2949. *
  2950. *
  2951. * @cython.cfunc # <<<<<<<<<<<<<<
  2952. * @cython.inline
  2953. * @cython.returns(cython.double)
  2954. */
  2955. static CYTHON_INLINE double __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_t_double_complex __pyx_v_v1, __pyx_t_double_complex __pyx_v_v2) {
  2956. double __pyx_v_result;
  2957. double __pyx_r;
  2958. double __pyx_t_1;
  2959. int __pyx_t_2;
  2960. /* "fontTools/cu2qu/cu2qu.py":51
  2961. * double: Dot product.
  2962. * """
  2963. * result = (v1 * v2.conjugate()).real # <<<<<<<<<<<<<<
  2964. * # When vectors are perpendicular (i.e. dot product is 0), the above expression may
  2965. * # yield slightly different results when running in pure Python vs C/Cython,
  2966. */
  2967. __pyx_t_1 = __Pyx_CREAL(__Pyx_c_prod_double(__pyx_v_v1, __Pyx_c_conj_double(__pyx_v_v2)));
  2968. __pyx_v_result = __pyx_t_1;
  2969. /* "fontTools/cu2qu/cu2qu.py":58
  2970. * # implementation. Because we are using the result in a denominator and catching
  2971. * # ZeroDivisionError (see `calc_intersect`), it's best to normalize the result here.
  2972. * if abs(result) < 1e-15: # <<<<<<<<<<<<<<
  2973. * result = 0.0
  2974. * return result
  2975. */
  2976. __pyx_t_1 = fabs(__pyx_v_result);
  2977. __pyx_t_2 = (__pyx_t_1 < 1e-15);
  2978. if (__pyx_t_2) {
  2979. /* "fontTools/cu2qu/cu2qu.py":59
  2980. * # ZeroDivisionError (see `calc_intersect`), it's best to normalize the result here.
  2981. * if abs(result) < 1e-15:
  2982. * result = 0.0 # <<<<<<<<<<<<<<
  2983. * return result
  2984. *
  2985. */
  2986. __pyx_v_result = 0.0;
  2987. /* "fontTools/cu2qu/cu2qu.py":58
  2988. * # implementation. Because we are using the result in a denominator and catching
  2989. * # ZeroDivisionError (see `calc_intersect`), it's best to normalize the result here.
  2990. * if abs(result) < 1e-15: # <<<<<<<<<<<<<<
  2991. * result = 0.0
  2992. * return result
  2993. */
  2994. }
  2995. /* "fontTools/cu2qu/cu2qu.py":60
  2996. * if abs(result) < 1e-15:
  2997. * result = 0.0
  2998. * return result # <<<<<<<<<<<<<<
  2999. *
  3000. *
  3001. */
  3002. __pyx_r = __pyx_v_result;
  3003. goto __pyx_L0;
  3004. /* "fontTools/cu2qu/cu2qu.py":37
  3005. *
  3006. *
  3007. * @cython.cfunc # <<<<<<<<<<<<<<
  3008. * @cython.inline
  3009. * @cython.returns(cython.double)
  3010. */
  3011. /* function exit code */
  3012. __pyx_L0:;
  3013. return __pyx_r;
  3014. }
  3015. /* "fontTools/cu2qu/cu2qu.py":63
  3016. *
  3017. *
  3018. * @cython.cfunc # <<<<<<<<<<<<<<
  3019. * @cython.locals(z=cython.complex, den=cython.double)
  3020. * @cython.locals(zr=cython.double, zi=cython.double)
  3021. */
  3022. static PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu__complex_div_by_real(__pyx_t_double_complex __pyx_v_z, double __pyx_v_den) {
  3023. double __pyx_v_zr;
  3024. double __pyx_v_zi;
  3025. PyObject *__pyx_r = NULL;
  3026. __Pyx_RefNannyDeclarations
  3027. double __pyx_t_1;
  3028. PyObject *__pyx_t_2 = NULL;
  3029. PyObject *__pyx_t_3 = NULL;
  3030. PyObject *__pyx_t_4 = NULL;
  3031. PyObject *__pyx_t_5 = NULL;
  3032. size_t __pyx_t_6;
  3033. int __pyx_lineno = 0;
  3034. const char *__pyx_filename = NULL;
  3035. int __pyx_clineno = 0;
  3036. __Pyx_RefNannySetupContext("_complex_div_by_real", 0);
  3037. /* "fontTools/cu2qu/cu2qu.py":75
  3038. * https://github.com/fonttools/fonttools/issues/3928
  3039. * """
  3040. * zr = z.real # <<<<<<<<<<<<<<
  3041. * zi = z.imag
  3042. * return complex(zr / den, zi / den)
  3043. */
  3044. __pyx_t_1 = __Pyx_CREAL(__pyx_v_z);
  3045. __pyx_v_zr = __pyx_t_1;
  3046. /* "fontTools/cu2qu/cu2qu.py":76
  3047. * """
  3048. * zr = z.real
  3049. * zi = z.imag # <<<<<<<<<<<<<<
  3050. * return complex(zr / den, zi / den)
  3051. *
  3052. */
  3053. __pyx_t_1 = __Pyx_CIMAG(__pyx_v_z);
  3054. __pyx_v_zi = __pyx_t_1;
  3055. /* "fontTools/cu2qu/cu2qu.py":77
  3056. * zr = z.real
  3057. * zi = z.imag
  3058. * return complex(zr / den, zi / den) # <<<<<<<<<<<<<<
  3059. *
  3060. *
  3061. */
  3062. __Pyx_XDECREF(__pyx_r);
  3063. __pyx_t_3 = NULL;
  3064. if (unlikely(__pyx_v_den == 0)) {
  3065. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  3066. __PYX_ERR(0, 77, __pyx_L1_error)
  3067. }
  3068. __pyx_t_4 = PyFloat_FromDouble((__pyx_v_zr / __pyx_v_den)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 77, __pyx_L1_error)
  3069. __Pyx_GOTREF(__pyx_t_4);
  3070. if (unlikely(__pyx_v_den == 0)) {
  3071. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  3072. __PYX_ERR(0, 77, __pyx_L1_error)
  3073. }
  3074. __pyx_t_5 = PyFloat_FromDouble((__pyx_v_zi / __pyx_v_den)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 77, __pyx_L1_error)
  3075. __Pyx_GOTREF(__pyx_t_5);
  3076. __pyx_t_6 = 1;
  3077. {
  3078. PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_t_4, __pyx_t_5};
  3079. __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));
  3080. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3081. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3082. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3083. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
  3084. __Pyx_GOTREF(__pyx_t_2);
  3085. }
  3086. __pyx_r = __pyx_t_2;
  3087. __pyx_t_2 = 0;
  3088. goto __pyx_L0;
  3089. /* "fontTools/cu2qu/cu2qu.py":63
  3090. *
  3091. *
  3092. * @cython.cfunc # <<<<<<<<<<<<<<
  3093. * @cython.locals(z=cython.complex, den=cython.double)
  3094. * @cython.locals(zr=cython.double, zi=cython.double)
  3095. */
  3096. /* function exit code */
  3097. __pyx_L1_error:;
  3098. __Pyx_XDECREF(__pyx_t_2);
  3099. __Pyx_XDECREF(__pyx_t_3);
  3100. __Pyx_XDECREF(__pyx_t_4);
  3101. __Pyx_XDECREF(__pyx_t_5);
  3102. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu._complex_div_by_real", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3103. __pyx_r = 0;
  3104. __pyx_L0:;
  3105. __Pyx_XGIVEREF(__pyx_r);
  3106. __Pyx_RefNannyFinishContext();
  3107. return __pyx_r;
  3108. }
  3109. /* "fontTools/cu2qu/cu2qu.py":80
  3110. *
  3111. *
  3112. * @cython.cfunc # <<<<<<<<<<<<<<
  3113. * @cython.inline
  3114. * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex)
  3115. */
  3116. 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) {
  3117. __pyx_t_double_complex __pyx_v__1;
  3118. __pyx_t_double_complex __pyx_v__2;
  3119. __pyx_t_double_complex __pyx_v__3;
  3120. __pyx_t_double_complex __pyx_v__4;
  3121. PyObject *__pyx_r = NULL;
  3122. __Pyx_RefNannyDeclarations
  3123. PyObject *__pyx_t_1 = NULL;
  3124. PyObject *__pyx_t_2 = NULL;
  3125. PyObject *__pyx_t_3 = NULL;
  3126. __pyx_t_double_complex __pyx_t_4;
  3127. PyObject *__pyx_t_5 = NULL;
  3128. PyObject *__pyx_t_6 = NULL;
  3129. int __pyx_lineno = 0;
  3130. const char *__pyx_filename = NULL;
  3131. int __pyx_clineno = 0;
  3132. __Pyx_RefNannySetupContext("calc_cubic_points", 0);
  3133. /* "fontTools/cu2qu/cu2qu.py":87
  3134. * )
  3135. * def calc_cubic_points(a, b, c, d):
  3136. * _1 = d # <<<<<<<<<<<<<<
  3137. * _2 = _complex_div_by_real(c, 3.0) + d
  3138. * _3 = _complex_div_by_real(b + c, 3.0) + _2
  3139. */
  3140. __pyx_v__1 = __pyx_v_d;
  3141. /* "fontTools/cu2qu/cu2qu.py":88
  3142. * def calc_cubic_points(a, b, c, d):
  3143. * _1 = d
  3144. * _2 = _complex_div_by_real(c, 3.0) + d # <<<<<<<<<<<<<<
  3145. * _3 = _complex_div_by_real(b + c, 3.0) + _2
  3146. * _4 = a + d + c + b
  3147. */
  3148. __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)
  3149. __Pyx_GOTREF(__pyx_t_1);
  3150. __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v_d); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
  3151. __Pyx_GOTREF(__pyx_t_2);
  3152. __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error)
  3153. __Pyx_GOTREF(__pyx_t_3);
  3154. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3155. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3156. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 88, __pyx_L1_error)
  3157. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3158. __pyx_v__2 = __pyx_t_4;
  3159. /* "fontTools/cu2qu/cu2qu.py":89
  3160. * _1 = d
  3161. * _2 = _complex_div_by_real(c, 3.0) + d
  3162. * _3 = _complex_div_by_real(b + c, 3.0) + _2 # <<<<<<<<<<<<<<
  3163. * _4 = a + d + c + b
  3164. * return _1, _2, _3, _4
  3165. */
  3166. __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)
  3167. __Pyx_GOTREF(__pyx_t_3);
  3168. __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v__2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
  3169. __Pyx_GOTREF(__pyx_t_2);
  3170. __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error)
  3171. __Pyx_GOTREF(__pyx_t_1);
  3172. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3173. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3174. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 89, __pyx_L1_error)
  3175. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3176. __pyx_v__3 = __pyx_t_4;
  3177. /* "fontTools/cu2qu/cu2qu.py":90
  3178. * _2 = _complex_div_by_real(c, 3.0) + d
  3179. * _3 = _complex_div_by_real(b + c, 3.0) + _2
  3180. * _4 = a + d + c + b # <<<<<<<<<<<<<<
  3181. * return _1, _2, _3, _4
  3182. *
  3183. */
  3184. __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);
  3185. /* "fontTools/cu2qu/cu2qu.py":91
  3186. * _3 = _complex_div_by_real(b + c, 3.0) + _2
  3187. * _4 = a + d + c + b
  3188. * return _1, _2, _3, _4 # <<<<<<<<<<<<<<
  3189. *
  3190. *
  3191. */
  3192. __Pyx_XDECREF(__pyx_r);
  3193. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v__1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
  3194. __Pyx_GOTREF(__pyx_t_1);
  3195. __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v__2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
  3196. __Pyx_GOTREF(__pyx_t_2);
  3197. __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_v__3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error)
  3198. __Pyx_GOTREF(__pyx_t_3);
  3199. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v__4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 91, __pyx_L1_error)
  3200. __Pyx_GOTREF(__pyx_t_5);
  3201. __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 91, __pyx_L1_error)
  3202. __Pyx_GOTREF(__pyx_t_6);
  3203. __Pyx_GIVEREF(__pyx_t_1);
  3204. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 91, __pyx_L1_error);
  3205. __Pyx_GIVEREF(__pyx_t_2);
  3206. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 91, __pyx_L1_error);
  3207. __Pyx_GIVEREF(__pyx_t_3);
  3208. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 91, __pyx_L1_error);
  3209. __Pyx_GIVEREF(__pyx_t_5);
  3210. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5) != (0)) __PYX_ERR(0, 91, __pyx_L1_error);
  3211. __pyx_t_1 = 0;
  3212. __pyx_t_2 = 0;
  3213. __pyx_t_3 = 0;
  3214. __pyx_t_5 = 0;
  3215. __pyx_r = __pyx_t_6;
  3216. __pyx_t_6 = 0;
  3217. goto __pyx_L0;
  3218. /* "fontTools/cu2qu/cu2qu.py":80
  3219. *
  3220. *
  3221. * @cython.cfunc # <<<<<<<<<<<<<<
  3222. * @cython.inline
  3223. * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex)
  3224. */
  3225. /* function exit code */
  3226. __pyx_L1_error:;
  3227. __Pyx_XDECREF(__pyx_t_1);
  3228. __Pyx_XDECREF(__pyx_t_2);
  3229. __Pyx_XDECREF(__pyx_t_3);
  3230. __Pyx_XDECREF(__pyx_t_5);
  3231. __Pyx_XDECREF(__pyx_t_6);
  3232. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_cubic_points", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3233. __pyx_r = 0;
  3234. __pyx_L0:;
  3235. __Pyx_XGIVEREF(__pyx_r);
  3236. __Pyx_RefNannyFinishContext();
  3237. return __pyx_r;
  3238. }
  3239. /* "fontTools/cu2qu/cu2qu.py":94
  3240. *
  3241. *
  3242. * @cython.cfunc # <<<<<<<<<<<<<<
  3243. * @cython.inline
  3244. * @cython.locals(
  3245. */
  3246. 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) {
  3247. __pyx_t_double_complex __pyx_v_a;
  3248. __pyx_t_double_complex __pyx_v_b;
  3249. __pyx_t_double_complex __pyx_v_c;
  3250. __pyx_t_double_complex __pyx_v_d;
  3251. PyObject *__pyx_r = NULL;
  3252. __Pyx_RefNannyDeclarations
  3253. PyObject *__pyx_t_1 = NULL;
  3254. PyObject *__pyx_t_2 = NULL;
  3255. PyObject *__pyx_t_3 = NULL;
  3256. PyObject *__pyx_t_4 = NULL;
  3257. PyObject *__pyx_t_5 = NULL;
  3258. int __pyx_lineno = 0;
  3259. const char *__pyx_filename = NULL;
  3260. int __pyx_clineno = 0;
  3261. __Pyx_RefNannySetupContext("calc_cubic_parameters", 0);
  3262. /* "fontTools/cu2qu/cu2qu.py":101
  3263. * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex)
  3264. * def calc_cubic_parameters(p0, p1, p2, p3):
  3265. * c = (p1 - p0) * 3.0 # <<<<<<<<<<<<<<
  3266. * b = (p2 - p1) * 3.0 - c
  3267. * d = p0
  3268. */
  3269. __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));
  3270. /* "fontTools/cu2qu/cu2qu.py":102
  3271. * def calc_cubic_parameters(p0, p1, p2, p3):
  3272. * c = (p1 - p0) * 3.0
  3273. * b = (p2 - p1) * 3.0 - c # <<<<<<<<<<<<<<
  3274. * d = p0
  3275. * a = p3 - d - c - b
  3276. */
  3277. __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);
  3278. /* "fontTools/cu2qu/cu2qu.py":103
  3279. * c = (p1 - p0) * 3.0
  3280. * b = (p2 - p1) * 3.0 - c
  3281. * d = p0 # <<<<<<<<<<<<<<
  3282. * a = p3 - d - c - b
  3283. * return a, b, c, d
  3284. */
  3285. __pyx_v_d = __pyx_v_p0;
  3286. /* "fontTools/cu2qu/cu2qu.py":104
  3287. * b = (p2 - p1) * 3.0 - c
  3288. * d = p0
  3289. * a = p3 - d - c - b # <<<<<<<<<<<<<<
  3290. * return a, b, c, d
  3291. *
  3292. */
  3293. __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);
  3294. /* "fontTools/cu2qu/cu2qu.py":105
  3295. * d = p0
  3296. * a = p3 - d - c - b
  3297. * return a, b, c, d # <<<<<<<<<<<<<<
  3298. *
  3299. *
  3300. */
  3301. __Pyx_XDECREF(__pyx_r);
  3302. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_a); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error)
  3303. __Pyx_GOTREF(__pyx_t_1);
  3304. __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v_b); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 105, __pyx_L1_error)
  3305. __Pyx_GOTREF(__pyx_t_2);
  3306. __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_v_c); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 105, __pyx_L1_error)
  3307. __Pyx_GOTREF(__pyx_t_3);
  3308. __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_v_d); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 105, __pyx_L1_error)
  3309. __Pyx_GOTREF(__pyx_t_4);
  3310. __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 105, __pyx_L1_error)
  3311. __Pyx_GOTREF(__pyx_t_5);
  3312. __Pyx_GIVEREF(__pyx_t_1);
  3313. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 105, __pyx_L1_error);
  3314. __Pyx_GIVEREF(__pyx_t_2);
  3315. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 105, __pyx_L1_error);
  3316. __Pyx_GIVEREF(__pyx_t_3);
  3317. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 105, __pyx_L1_error);
  3318. __Pyx_GIVEREF(__pyx_t_4);
  3319. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4) != (0)) __PYX_ERR(0, 105, __pyx_L1_error);
  3320. __pyx_t_1 = 0;
  3321. __pyx_t_2 = 0;
  3322. __pyx_t_3 = 0;
  3323. __pyx_t_4 = 0;
  3324. __pyx_r = __pyx_t_5;
  3325. __pyx_t_5 = 0;
  3326. goto __pyx_L0;
  3327. /* "fontTools/cu2qu/cu2qu.py":94
  3328. *
  3329. *
  3330. * @cython.cfunc # <<<<<<<<<<<<<<
  3331. * @cython.inline
  3332. * @cython.locals(
  3333. */
  3334. /* function exit code */
  3335. __pyx_L1_error:;
  3336. __Pyx_XDECREF(__pyx_t_1);
  3337. __Pyx_XDECREF(__pyx_t_2);
  3338. __Pyx_XDECREF(__pyx_t_3);
  3339. __Pyx_XDECREF(__pyx_t_4);
  3340. __Pyx_XDECREF(__pyx_t_5);
  3341. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_cubic_parameters", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3342. __pyx_r = 0;
  3343. __pyx_L0:;
  3344. __Pyx_XGIVEREF(__pyx_r);
  3345. __Pyx_RefNannyFinishContext();
  3346. return __pyx_r;
  3347. }
  3348. /* "fontTools/cu2qu/cu2qu.py":108
  3349. *
  3350. *
  3351. * @cython.cfunc # <<<<<<<<<<<<<<
  3352. * @cython.inline
  3353. * @cython.locals(
  3354. */
  3355. 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) {
  3356. PyObject *__pyx_v_a = NULL;
  3357. PyObject *__pyx_v_b = NULL;
  3358. PyObject *__pyx_r = NULL;
  3359. __Pyx_RefNannyDeclarations
  3360. int __pyx_t_1;
  3361. PyObject *__pyx_t_2 = NULL;
  3362. PyObject *__pyx_t_3 = NULL;
  3363. PyObject *__pyx_t_4 = NULL;
  3364. PyObject *__pyx_t_5 = NULL;
  3365. PyObject *(*__pyx_t_6)(PyObject *);
  3366. __pyx_t_double_complex __pyx_t_7;
  3367. __pyx_t_double_complex __pyx_t_8;
  3368. __pyx_t_double_complex __pyx_t_9;
  3369. __pyx_t_double_complex __pyx_t_10;
  3370. PyObject *__pyx_t_11 = NULL;
  3371. PyObject *__pyx_t_12 = NULL;
  3372. PyObject *__pyx_t_13 = NULL;
  3373. size_t __pyx_t_14;
  3374. int __pyx_lineno = 0;
  3375. const char *__pyx_filename = NULL;
  3376. int __pyx_clineno = 0;
  3377. __Pyx_RefNannySetupContext("split_cubic_into_n_iter", 0);
  3378. /* "fontTools/cu2qu/cu2qu.py":130
  3379. * """
  3380. * # Hand-coded special-cases
  3381. * if n == 2: # <<<<<<<<<<<<<<
  3382. * return iter(split_cubic_into_two(p0, p1, p2, p3))
  3383. * if n == 3:
  3384. */
  3385. __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)
  3386. if (__pyx_t_1) {
  3387. /* "fontTools/cu2qu/cu2qu.py":131
  3388. * # Hand-coded special-cases
  3389. * if n == 2:
  3390. * return iter(split_cubic_into_two(p0, p1, p2, p3)) # <<<<<<<<<<<<<<
  3391. * if n == 3:
  3392. * return iter(split_cubic_into_three(p0, p1, p2, p3))
  3393. */
  3394. __Pyx_XDECREF(__pyx_r);
  3395. __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)
  3396. __Pyx_GOTREF(__pyx_t_2);
  3397. __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 131, __pyx_L1_error)
  3398. __Pyx_GOTREF(__pyx_t_3);
  3399. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3400. __pyx_r = __pyx_t_3;
  3401. __pyx_t_3 = 0;
  3402. goto __pyx_L0;
  3403. /* "fontTools/cu2qu/cu2qu.py":130
  3404. * """
  3405. * # Hand-coded special-cases
  3406. * if n == 2: # <<<<<<<<<<<<<<
  3407. * return iter(split_cubic_into_two(p0, p1, p2, p3))
  3408. * if n == 3:
  3409. */
  3410. }
  3411. /* "fontTools/cu2qu/cu2qu.py":132
  3412. * if n == 2:
  3413. * return iter(split_cubic_into_two(p0, p1, p2, p3))
  3414. * if n == 3: # <<<<<<<<<<<<<<
  3415. * return iter(split_cubic_into_three(p0, p1, p2, p3))
  3416. * if n == 4:
  3417. */
  3418. __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)
  3419. if (__pyx_t_1) {
  3420. /* "fontTools/cu2qu/cu2qu.py":133
  3421. * return iter(split_cubic_into_two(p0, p1, p2, p3))
  3422. * if n == 3:
  3423. * return iter(split_cubic_into_three(p0, p1, p2, p3)) # <<<<<<<<<<<<<<
  3424. * if n == 4:
  3425. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3426. */
  3427. __Pyx_XDECREF(__pyx_r);
  3428. __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)
  3429. __Pyx_GOTREF(__pyx_t_3);
  3430. __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
  3431. __Pyx_GOTREF(__pyx_t_2);
  3432. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3433. __pyx_r = __pyx_t_2;
  3434. __pyx_t_2 = 0;
  3435. goto __pyx_L0;
  3436. /* "fontTools/cu2qu/cu2qu.py":132
  3437. * if n == 2:
  3438. * return iter(split_cubic_into_two(p0, p1, p2, p3))
  3439. * if n == 3: # <<<<<<<<<<<<<<
  3440. * return iter(split_cubic_into_three(p0, p1, p2, p3))
  3441. * if n == 4:
  3442. */
  3443. }
  3444. /* "fontTools/cu2qu/cu2qu.py":134
  3445. * if n == 3:
  3446. * return iter(split_cubic_into_three(p0, p1, p2, p3))
  3447. * if n == 4: # <<<<<<<<<<<<<<
  3448. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3449. * return iter(
  3450. */
  3451. __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)
  3452. if (__pyx_t_1) {
  3453. /* "fontTools/cu2qu/cu2qu.py":135
  3454. * return iter(split_cubic_into_three(p0, p1, p2, p3))
  3455. * if n == 4:
  3456. * a, b = split_cubic_into_two(p0, p1, p2, p3) # <<<<<<<<<<<<<<
  3457. * return iter(
  3458. * split_cubic_into_two(a[0], a[1], a[2], a[3])
  3459. */
  3460. __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)
  3461. __Pyx_GOTREF(__pyx_t_2);
  3462. if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
  3463. PyObject* sequence = __pyx_t_2;
  3464. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  3465. if (unlikely(size != 2)) {
  3466. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  3467. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  3468. __PYX_ERR(0, 135, __pyx_L1_error)
  3469. }
  3470. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  3471. if (likely(PyTuple_CheckExact(sequence))) {
  3472. __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
  3473. __Pyx_INCREF(__pyx_t_3);
  3474. __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
  3475. __Pyx_INCREF(__pyx_t_4);
  3476. } else {
  3477. __pyx_t_3 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  3478. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
  3479. __Pyx_XGOTREF(__pyx_t_3);
  3480. __pyx_t_4 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  3481. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 135, __pyx_L1_error)
  3482. __Pyx_XGOTREF(__pyx_t_4);
  3483. }
  3484. #else
  3485. __pyx_t_3 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
  3486. __Pyx_GOTREF(__pyx_t_3);
  3487. __pyx_t_4 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 135, __pyx_L1_error)
  3488. __Pyx_GOTREF(__pyx_t_4);
  3489. #endif
  3490. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3491. } else {
  3492. Py_ssize_t index = -1;
  3493. __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 135, __pyx_L1_error)
  3494. __Pyx_GOTREF(__pyx_t_5);
  3495. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3496. __pyx_t_6 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5);
  3497. index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
  3498. __Pyx_GOTREF(__pyx_t_3);
  3499. index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
  3500. __Pyx_GOTREF(__pyx_t_4);
  3501. if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < (0)) __PYX_ERR(0, 135, __pyx_L1_error)
  3502. __pyx_t_6 = NULL;
  3503. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3504. goto __pyx_L7_unpacking_done;
  3505. __pyx_L6_unpacking_failed:;
  3506. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3507. __pyx_t_6 = NULL;
  3508. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  3509. __PYX_ERR(0, 135, __pyx_L1_error)
  3510. __pyx_L7_unpacking_done:;
  3511. }
  3512. __pyx_v_a = __pyx_t_3;
  3513. __pyx_t_3 = 0;
  3514. __pyx_v_b = __pyx_t_4;
  3515. __pyx_t_4 = 0;
  3516. /* "fontTools/cu2qu/cu2qu.py":136
  3517. * if n == 4:
  3518. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3519. * return iter( # <<<<<<<<<<<<<<
  3520. * split_cubic_into_two(a[0], a[1], a[2], a[3])
  3521. * + split_cubic_into_two(b[0], b[1], b[2], b[3])
  3522. */
  3523. __Pyx_XDECREF(__pyx_r);
  3524. /* "fontTools/cu2qu/cu2qu.py":137
  3525. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3526. * return iter(
  3527. * split_cubic_into_two(a[0], a[1], a[2], a[3]) # <<<<<<<<<<<<<<
  3528. * + split_cubic_into_two(b[0], b[1], b[2], b[3])
  3529. * )
  3530. */
  3531. __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)
  3532. __Pyx_GOTREF(__pyx_t_2);
  3533. __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L1_error)
  3534. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3535. __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)
  3536. __Pyx_GOTREF(__pyx_t_2);
  3537. __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L1_error)
  3538. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3539. __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)
  3540. __Pyx_GOTREF(__pyx_t_2);
  3541. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L1_error)
  3542. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3543. __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)
  3544. __Pyx_GOTREF(__pyx_t_2);
  3545. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L1_error)
  3546. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3547. __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)
  3548. __Pyx_GOTREF(__pyx_t_2);
  3549. /* "fontTools/cu2qu/cu2qu.py":138
  3550. * return iter(
  3551. * split_cubic_into_two(a[0], a[1], a[2], a[3])
  3552. * + split_cubic_into_two(b[0], b[1], b[2], b[3]) # <<<<<<<<<<<<<<
  3553. * )
  3554. * if n == 6:
  3555. */
  3556. __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)
  3557. __Pyx_GOTREF(__pyx_t_4);
  3558. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 138, __pyx_L1_error)
  3559. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3560. __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)
  3561. __Pyx_GOTREF(__pyx_t_4);
  3562. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 138, __pyx_L1_error)
  3563. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3564. __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)
  3565. __Pyx_GOTREF(__pyx_t_4);
  3566. __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 138, __pyx_L1_error)
  3567. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3568. __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)
  3569. __Pyx_GOTREF(__pyx_t_4);
  3570. __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 138, __pyx_L1_error)
  3571. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3572. __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)
  3573. __Pyx_GOTREF(__pyx_t_4);
  3574. __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error)
  3575. __Pyx_GOTREF(__pyx_t_3);
  3576. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3577. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3578. /* "fontTools/cu2qu/cu2qu.py":136
  3579. * if n == 4:
  3580. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3581. * return iter( # <<<<<<<<<<<<<<
  3582. * split_cubic_into_two(a[0], a[1], a[2], a[3])
  3583. * + split_cubic_into_two(b[0], b[1], b[2], b[3])
  3584. */
  3585. __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 136, __pyx_L1_error)
  3586. __Pyx_GOTREF(__pyx_t_4);
  3587. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3588. __pyx_r = __pyx_t_4;
  3589. __pyx_t_4 = 0;
  3590. goto __pyx_L0;
  3591. /* "fontTools/cu2qu/cu2qu.py":134
  3592. * if n == 3:
  3593. * return iter(split_cubic_into_three(p0, p1, p2, p3))
  3594. * if n == 4: # <<<<<<<<<<<<<<
  3595. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3596. * return iter(
  3597. */
  3598. }
  3599. /* "fontTools/cu2qu/cu2qu.py":140
  3600. * + split_cubic_into_two(b[0], b[1], b[2], b[3])
  3601. * )
  3602. * if n == 6: # <<<<<<<<<<<<<<
  3603. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3604. * return iter(
  3605. */
  3606. __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)
  3607. if (__pyx_t_1) {
  3608. /* "fontTools/cu2qu/cu2qu.py":141
  3609. * )
  3610. * if n == 6:
  3611. * a, b = split_cubic_into_two(p0, p1, p2, p3) # <<<<<<<<<<<<<<
  3612. * return iter(
  3613. * split_cubic_into_three(a[0], a[1], a[2], a[3])
  3614. */
  3615. __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)
  3616. __Pyx_GOTREF(__pyx_t_4);
  3617. if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
  3618. PyObject* sequence = __pyx_t_4;
  3619. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  3620. if (unlikely(size != 2)) {
  3621. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  3622. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  3623. __PYX_ERR(0, 141, __pyx_L1_error)
  3624. }
  3625. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  3626. if (likely(PyTuple_CheckExact(sequence))) {
  3627. __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
  3628. __Pyx_INCREF(__pyx_t_3);
  3629. __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
  3630. __Pyx_INCREF(__pyx_t_2);
  3631. } else {
  3632. __pyx_t_3 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  3633. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error)
  3634. __Pyx_XGOTREF(__pyx_t_3);
  3635. __pyx_t_2 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  3636. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
  3637. __Pyx_XGOTREF(__pyx_t_2);
  3638. }
  3639. #else
  3640. __pyx_t_3 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error)
  3641. __Pyx_GOTREF(__pyx_t_3);
  3642. __pyx_t_2 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
  3643. __Pyx_GOTREF(__pyx_t_2);
  3644. #endif
  3645. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3646. } else {
  3647. Py_ssize_t index = -1;
  3648. __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 141, __pyx_L1_error)
  3649. __Pyx_GOTREF(__pyx_t_5);
  3650. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3651. __pyx_t_6 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5);
  3652. index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L9_unpacking_failed;
  3653. __Pyx_GOTREF(__pyx_t_3);
  3654. index = 1; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed;
  3655. __Pyx_GOTREF(__pyx_t_2);
  3656. if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < (0)) __PYX_ERR(0, 141, __pyx_L1_error)
  3657. __pyx_t_6 = NULL;
  3658. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3659. goto __pyx_L10_unpacking_done;
  3660. __pyx_L9_unpacking_failed:;
  3661. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3662. __pyx_t_6 = NULL;
  3663. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  3664. __PYX_ERR(0, 141, __pyx_L1_error)
  3665. __pyx_L10_unpacking_done:;
  3666. }
  3667. __pyx_v_a = __pyx_t_3;
  3668. __pyx_t_3 = 0;
  3669. __pyx_v_b = __pyx_t_2;
  3670. __pyx_t_2 = 0;
  3671. /* "fontTools/cu2qu/cu2qu.py":142
  3672. * if n == 6:
  3673. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3674. * return iter( # <<<<<<<<<<<<<<
  3675. * split_cubic_into_three(a[0], a[1], a[2], a[3])
  3676. * + split_cubic_into_three(b[0], b[1], b[2], b[3])
  3677. */
  3678. __Pyx_XDECREF(__pyx_r);
  3679. /* "fontTools/cu2qu/cu2qu.py":143
  3680. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3681. * return iter(
  3682. * split_cubic_into_three(a[0], a[1], a[2], a[3]) # <<<<<<<<<<<<<<
  3683. * + split_cubic_into_three(b[0], b[1], b[2], b[3])
  3684. * )
  3685. */
  3686. __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)
  3687. __Pyx_GOTREF(__pyx_t_4);
  3688. __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
  3689. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3690. __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)
  3691. __Pyx_GOTREF(__pyx_t_4);
  3692. __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
  3693. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3694. __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)
  3695. __Pyx_GOTREF(__pyx_t_4);
  3696. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
  3697. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3698. __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)
  3699. __Pyx_GOTREF(__pyx_t_4);
  3700. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
  3701. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3702. __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)
  3703. __Pyx_GOTREF(__pyx_t_4);
  3704. /* "fontTools/cu2qu/cu2qu.py":144
  3705. * return iter(
  3706. * split_cubic_into_three(a[0], a[1], a[2], a[3])
  3707. * + split_cubic_into_three(b[0], b[1], b[2], b[3]) # <<<<<<<<<<<<<<
  3708. * )
  3709. *
  3710. */
  3711. __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)
  3712. __Pyx_GOTREF(__pyx_t_2);
  3713. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 144, __pyx_L1_error)
  3714. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3715. __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)
  3716. __Pyx_GOTREF(__pyx_t_2);
  3717. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 144, __pyx_L1_error)
  3718. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3719. __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)
  3720. __Pyx_GOTREF(__pyx_t_2);
  3721. __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 144, __pyx_L1_error)
  3722. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3723. __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)
  3724. __Pyx_GOTREF(__pyx_t_2);
  3725. __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 144, __pyx_L1_error)
  3726. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3727. __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)
  3728. __Pyx_GOTREF(__pyx_t_2);
  3729. __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error)
  3730. __Pyx_GOTREF(__pyx_t_3);
  3731. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3732. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3733. /* "fontTools/cu2qu/cu2qu.py":142
  3734. * if n == 6:
  3735. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3736. * return iter( # <<<<<<<<<<<<<<
  3737. * split_cubic_into_three(a[0], a[1], a[2], a[3])
  3738. * + split_cubic_into_three(b[0], b[1], b[2], b[3])
  3739. */
  3740. __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error)
  3741. __Pyx_GOTREF(__pyx_t_2);
  3742. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3743. __pyx_r = __pyx_t_2;
  3744. __pyx_t_2 = 0;
  3745. goto __pyx_L0;
  3746. /* "fontTools/cu2qu/cu2qu.py":140
  3747. * + split_cubic_into_two(b[0], b[1], b[2], b[3])
  3748. * )
  3749. * if n == 6: # <<<<<<<<<<<<<<
  3750. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3751. * return iter(
  3752. */
  3753. }
  3754. /* "fontTools/cu2qu/cu2qu.py":147
  3755. * )
  3756. *
  3757. * return _split_cubic_into_n_gen(p0, p1, p2, p3, n) # <<<<<<<<<<<<<<
  3758. *
  3759. *
  3760. */
  3761. __Pyx_XDECREF(__pyx_r);
  3762. __pyx_t_3 = NULL;
  3763. __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)
  3764. __Pyx_GOTREF(__pyx_t_4);
  3765. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error)
  3766. __Pyx_GOTREF(__pyx_t_5);
  3767. __pyx_t_11 = __pyx_PyComplex_FromComplex(__pyx_v_p1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 147, __pyx_L1_error)
  3768. __Pyx_GOTREF(__pyx_t_11);
  3769. __pyx_t_12 = __pyx_PyComplex_FromComplex(__pyx_v_p2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 147, __pyx_L1_error)
  3770. __Pyx_GOTREF(__pyx_t_12);
  3771. __pyx_t_13 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 147, __pyx_L1_error)
  3772. __Pyx_GOTREF(__pyx_t_13);
  3773. __pyx_t_14 = 1;
  3774. #if CYTHON_UNPACK_METHODS
  3775. if (unlikely(PyMethod_Check(__pyx_t_4))) {
  3776. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
  3777. assert(__pyx_t_3);
  3778. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
  3779. __Pyx_INCREF(__pyx_t_3);
  3780. __Pyx_INCREF(__pyx__function);
  3781. __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
  3782. __pyx_t_14 = 0;
  3783. }
  3784. #endif
  3785. {
  3786. PyObject *__pyx_callargs[6] = {__pyx_t_3, __pyx_t_5, __pyx_t_11, __pyx_t_12, __pyx_t_13, __pyx_v_n};
  3787. __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));
  3788. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3789. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3790. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  3791. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  3792. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  3793. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3794. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error)
  3795. __Pyx_GOTREF(__pyx_t_2);
  3796. }
  3797. __pyx_r = __pyx_t_2;
  3798. __pyx_t_2 = 0;
  3799. goto __pyx_L0;
  3800. /* "fontTools/cu2qu/cu2qu.py":108
  3801. *
  3802. *
  3803. * @cython.cfunc # <<<<<<<<<<<<<<
  3804. * @cython.inline
  3805. * @cython.locals(
  3806. */
  3807. /* function exit code */
  3808. __pyx_L1_error:;
  3809. __Pyx_XDECREF(__pyx_t_2);
  3810. __Pyx_XDECREF(__pyx_t_3);
  3811. __Pyx_XDECREF(__pyx_t_4);
  3812. __Pyx_XDECREF(__pyx_t_5);
  3813. __Pyx_XDECREF(__pyx_t_11);
  3814. __Pyx_XDECREF(__pyx_t_12);
  3815. __Pyx_XDECREF(__pyx_t_13);
  3816. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.split_cubic_into_n_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3817. __pyx_r = 0;
  3818. __pyx_L0:;
  3819. __Pyx_XDECREF(__pyx_v_a);
  3820. __Pyx_XDECREF(__pyx_v_b);
  3821. __Pyx_XGIVEREF(__pyx_r);
  3822. __Pyx_RefNannyFinishContext();
  3823. return __pyx_r;
  3824. }
  3825. static PyObject *__pyx_gb_9fontTools_5cu2qu_5cu2qu_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
  3826. /* "fontTools/cu2qu/cu2qu.py":150
  3827. *
  3828. *
  3829. * @cython.locals( # <<<<<<<<<<<<<<
  3830. * p0=cython.complex,
  3831. * p1=cython.complex,
  3832. */
  3833. /* Python wrapper */
  3834. static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen(PyObject *__pyx_self,
  3835. #if CYTHON_METH_FASTCALL
  3836. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  3837. #else
  3838. PyObject *__pyx_args, PyObject *__pyx_kwds
  3839. #endif
  3840. ); /*proto*/
  3841. 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)");
  3842. 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};
  3843. static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen(PyObject *__pyx_self,
  3844. #if CYTHON_METH_FASTCALL
  3845. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  3846. #else
  3847. PyObject *__pyx_args, PyObject *__pyx_kwds
  3848. #endif
  3849. ) {
  3850. __pyx_t_double_complex __pyx_v_p0;
  3851. __pyx_t_double_complex __pyx_v_p1;
  3852. __pyx_t_double_complex __pyx_v_p2;
  3853. __pyx_t_double_complex __pyx_v_p3;
  3854. int __pyx_v_n;
  3855. #if !CYTHON_METH_FASTCALL
  3856. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  3857. #endif
  3858. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  3859. PyObject* values[5] = {0,0,0,0,0};
  3860. int __pyx_lineno = 0;
  3861. const char *__pyx_filename = NULL;
  3862. int __pyx_clineno = 0;
  3863. PyObject *__pyx_r = 0;
  3864. __Pyx_RefNannyDeclarations
  3865. __Pyx_RefNannySetupContext("_split_cubic_into_n_gen (wrapper)", 0);
  3866. #if !CYTHON_METH_FASTCALL
  3867. #if CYTHON_ASSUME_SAFE_SIZE
  3868. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  3869. #else
  3870. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  3871. #endif
  3872. #endif
  3873. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  3874. {
  3875. 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};
  3876. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  3877. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 150, __pyx_L3_error)
  3878. if (__pyx_kwds_len > 0) {
  3879. switch (__pyx_nargs) {
  3880. case 5:
  3881. values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
  3882. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 150, __pyx_L3_error)
  3883. CYTHON_FALLTHROUGH;
  3884. case 4:
  3885. values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
  3886. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 150, __pyx_L3_error)
  3887. CYTHON_FALLTHROUGH;
  3888. case 3:
  3889. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  3890. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 150, __pyx_L3_error)
  3891. CYTHON_FALLTHROUGH;
  3892. case 2:
  3893. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  3894. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 150, __pyx_L3_error)
  3895. CYTHON_FALLTHROUGH;
  3896. case 1:
  3897. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  3898. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 150, __pyx_L3_error)
  3899. CYTHON_FALLTHROUGH;
  3900. case 0: break;
  3901. default: goto __pyx_L5_argtuple_error;
  3902. }
  3903. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  3904. 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)
  3905. for (Py_ssize_t i = __pyx_nargs; i < 5; i++) {
  3906. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, i); __PYX_ERR(0, 150, __pyx_L3_error) }
  3907. }
  3908. } else if (unlikely(__pyx_nargs != 5)) {
  3909. goto __pyx_L5_argtuple_error;
  3910. } else {
  3911. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  3912. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 150, __pyx_L3_error)
  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. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  3916. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 150, __pyx_L3_error)
  3917. values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
  3918. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 150, __pyx_L3_error)
  3919. values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
  3920. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 150, __pyx_L3_error)
  3921. }
  3922. __pyx_v_p0 = __Pyx_PyComplex_As___pyx_t_double_complex(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error)
  3923. __pyx_v_p1 = __Pyx_PyComplex_As___pyx_t_double_complex(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error)
  3924. __pyx_v_p2 = __Pyx_PyComplex_As___pyx_t_double_complex(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error)
  3925. __pyx_v_p3 = __Pyx_PyComplex_As___pyx_t_double_complex(values[3]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error)
  3926. __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)
  3927. }
  3928. goto __pyx_L6_skip;
  3929. __pyx_L5_argtuple_error:;
  3930. __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, __pyx_nargs); __PYX_ERR(0, 150, __pyx_L3_error)
  3931. __pyx_L6_skip:;
  3932. goto __pyx_L4_argument_unpacking_done;
  3933. __pyx_L3_error:;
  3934. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  3935. Py_XDECREF(values[__pyx_temp]);
  3936. }
  3937. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu._split_cubic_into_n_gen", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3938. __Pyx_RefNannyFinishContext();
  3939. return NULL;
  3940. __pyx_L4_argument_unpacking_done:;
  3941. __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);
  3942. /* function exit code */
  3943. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  3944. Py_XDECREF(values[__pyx_temp]);
  3945. }
  3946. __Pyx_RefNannyFinishContext();
  3947. return __pyx_r;
  3948. }
  3949. 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) {
  3950. struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *__pyx_cur_scope;
  3951. PyObject *__pyx_r = NULL;
  3952. __Pyx_RefNannyDeclarations
  3953. int __pyx_lineno = 0;
  3954. const char *__pyx_filename = NULL;
  3955. int __pyx_clineno = 0;
  3956. __Pyx_RefNannySetupContext("_split_cubic_into_n_gen", 0);
  3957. __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);
  3958. if (unlikely(!__pyx_cur_scope)) {
  3959. __pyx_cur_scope = ((struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *)Py_None);
  3960. __Pyx_INCREF(Py_None);
  3961. __PYX_ERR(0, 150, __pyx_L1_error)
  3962. } else {
  3963. __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  3964. }
  3965. __pyx_cur_scope->__pyx_v_p0 = __pyx_v_p0;
  3966. __pyx_cur_scope->__pyx_v_p1 = __pyx_v_p1;
  3967. __pyx_cur_scope->__pyx_v_p2 = __pyx_v_p2;
  3968. __pyx_cur_scope->__pyx_v_p3 = __pyx_v_p3;
  3969. __pyx_cur_scope->__pyx_v_n = __pyx_v_n;
  3970. {
  3971. __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)
  3972. __Pyx_DECREF(__pyx_cur_scope);
  3973. __Pyx_RefNannyFinishContext();
  3974. return (PyObject *) gen;
  3975. }
  3976. /* function exit code */
  3977. __pyx_L1_error:;
  3978. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu._split_cubic_into_n_gen", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3979. __pyx_r = NULL;
  3980. __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  3981. __Pyx_XGIVEREF(__pyx_r);
  3982. __Pyx_RefNannyFinishContext();
  3983. return __pyx_r;
  3984. }
  3985. static PyObject *__pyx_gb_9fontTools_5cu2qu_5cu2qu_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
  3986. {
  3987. 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);
  3988. PyObject *__pyx_r = NULL;
  3989. PyObject *__pyx_t_1 = NULL;
  3990. PyObject *__pyx_t_2 = NULL;
  3991. PyObject *__pyx_t_3 = NULL;
  3992. PyObject *__pyx_t_4 = NULL;
  3993. PyObject *__pyx_t_5 = NULL;
  3994. PyObject *__pyx_t_6 = NULL;
  3995. PyObject *(*__pyx_t_7)(PyObject *);
  3996. __pyx_t_double_complex __pyx_t_8;
  3997. __pyx_t_double_complex __pyx_t_9;
  3998. __pyx_t_double_complex __pyx_t_10;
  3999. __pyx_t_double_complex __pyx_t_11;
  4000. int __pyx_t_12;
  4001. int __pyx_t_13;
  4002. int __pyx_t_14;
  4003. int __pyx_lineno = 0;
  4004. const char *__pyx_filename = NULL;
  4005. int __pyx_clineno = 0;
  4006. __Pyx_RefNannyDeclarations
  4007. __Pyx_RefNannySetupContext("_split_cubic_into_n_gen", 0);
  4008. switch (__pyx_generator->resume_label) {
  4009. case 0: goto __pyx_L3_first_run;
  4010. case 1: goto __pyx_L8_resume_from_yield;
  4011. default: /* CPython raises the right error here */
  4012. __Pyx_RefNannyFinishContext();
  4013. return NULL;
  4014. }
  4015. __pyx_L3_first_run:;
  4016. if (unlikely(__pyx_sent_value != Py_None)) {
  4017. if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started generator");
  4018. __PYX_ERR(0, 150, __pyx_L1_error)
  4019. }
  4020. /* "fontTools/cu2qu/cu2qu.py":165
  4021. * )
  4022. * def _split_cubic_into_n_gen(p0, p1, p2, p3, n):
  4023. * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) # <<<<<<<<<<<<<<
  4024. * dt = 1 / n
  4025. * delta_2 = dt * dt
  4026. */
  4027. __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)
  4028. __Pyx_GOTREF(__pyx_t_1);
  4029. if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
  4030. PyObject* sequence = __pyx_t_1;
  4031. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  4032. if (unlikely(size != 4)) {
  4033. if (size > 4) __Pyx_RaiseTooManyValuesError(4);
  4034. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  4035. __PYX_ERR(0, 165, __pyx_L1_error)
  4036. }
  4037. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4038. if (likely(PyTuple_CheckExact(sequence))) {
  4039. __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
  4040. __Pyx_INCREF(__pyx_t_2);
  4041. __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
  4042. __Pyx_INCREF(__pyx_t_3);
  4043. __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2);
  4044. __Pyx_INCREF(__pyx_t_4);
  4045. __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3);
  4046. __Pyx_INCREF(__pyx_t_5);
  4047. } else {
  4048. __pyx_t_2 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  4049. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 165, __pyx_L1_error)
  4050. __Pyx_XGOTREF(__pyx_t_2);
  4051. __pyx_t_3 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  4052. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 165, __pyx_L1_error)
  4053. __Pyx_XGOTREF(__pyx_t_3);
  4054. __pyx_t_4 = __Pyx_PyList_GetItemRefFast(sequence, 2, __Pyx_ReferenceSharing_SharedReference);
  4055. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 165, __pyx_L1_error)
  4056. __Pyx_XGOTREF(__pyx_t_4);
  4057. __pyx_t_5 = __Pyx_PyList_GetItemRefFast(sequence, 3, __Pyx_ReferenceSharing_SharedReference);
  4058. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 165, __pyx_L1_error)
  4059. __Pyx_XGOTREF(__pyx_t_5);
  4060. }
  4061. #else
  4062. {
  4063. Py_ssize_t i;
  4064. PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5};
  4065. for (i=0; i < 4; i++) {
  4066. PyObject* item = __Pyx_PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 165, __pyx_L1_error)
  4067. __Pyx_GOTREF(item);
  4068. *(temps[i]) = item;
  4069. }
  4070. }
  4071. #endif
  4072. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4073. } else {
  4074. Py_ssize_t index = -1;
  4075. PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5};
  4076. __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 165, __pyx_L1_error)
  4077. __Pyx_GOTREF(__pyx_t_6);
  4078. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4079. __pyx_t_7 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6);
  4080. for (index=0; index < 4; index++) {
  4081. PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L4_unpacking_failed;
  4082. __Pyx_GOTREF(item);
  4083. *(temps[index]) = item;
  4084. }
  4085. if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < (0)) __PYX_ERR(0, 165, __pyx_L1_error)
  4086. __pyx_t_7 = NULL;
  4087. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4088. goto __pyx_L5_unpacking_done;
  4089. __pyx_L4_unpacking_failed:;
  4090. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4091. __pyx_t_7 = NULL;
  4092. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  4093. __PYX_ERR(0, 165, __pyx_L1_error)
  4094. __pyx_L5_unpacking_done:;
  4095. }
  4096. __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error)
  4097. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4098. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error)
  4099. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4100. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error)
  4101. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4102. __pyx_t_11 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error)
  4103. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4104. __pyx_cur_scope->__pyx_v_a = __pyx_t_8;
  4105. __pyx_cur_scope->__pyx_v_b = __pyx_t_9;
  4106. __pyx_cur_scope->__pyx_v_c = __pyx_t_10;
  4107. __pyx_cur_scope->__pyx_v_d = __pyx_t_11;
  4108. /* "fontTools/cu2qu/cu2qu.py":166
  4109. * def _split_cubic_into_n_gen(p0, p1, p2, p3, n):
  4110. * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3)
  4111. * dt = 1 / n # <<<<<<<<<<<<<<
  4112. * delta_2 = dt * dt
  4113. * delta_3 = dt * delta_2
  4114. */
  4115. if (unlikely(__pyx_cur_scope->__pyx_v_n == 0)) {
  4116. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  4117. __PYX_ERR(0, 166, __pyx_L1_error)
  4118. }
  4119. __pyx_cur_scope->__pyx_v_dt = (1.0 / ((double)__pyx_cur_scope->__pyx_v_n));
  4120. /* "fontTools/cu2qu/cu2qu.py":167
  4121. * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3)
  4122. * dt = 1 / n
  4123. * delta_2 = dt * dt # <<<<<<<<<<<<<<
  4124. * delta_3 = dt * delta_2
  4125. * for i in range(n):
  4126. */
  4127. __pyx_cur_scope->__pyx_v_delta_2 = (__pyx_cur_scope->__pyx_v_dt * __pyx_cur_scope->__pyx_v_dt);
  4128. /* "fontTools/cu2qu/cu2qu.py":168
  4129. * dt = 1 / n
  4130. * delta_2 = dt * dt
  4131. * delta_3 = dt * delta_2 # <<<<<<<<<<<<<<
  4132. * for i in range(n):
  4133. * t1 = i * dt
  4134. */
  4135. __pyx_cur_scope->__pyx_v_delta_3 = (__pyx_cur_scope->__pyx_v_dt * __pyx_cur_scope->__pyx_v_delta_2);
  4136. /* "fontTools/cu2qu/cu2qu.py":169
  4137. * delta_2 = dt * dt
  4138. * delta_3 = dt * delta_2
  4139. * for i in range(n): # <<<<<<<<<<<<<<
  4140. * t1 = i * dt
  4141. * t1_2 = t1 * t1
  4142. */
  4143. __pyx_t_12 = __pyx_cur_scope->__pyx_v_n;
  4144. __pyx_t_13 = __pyx_t_12;
  4145. for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
  4146. __pyx_cur_scope->__pyx_v_i = __pyx_t_14;
  4147. /* "fontTools/cu2qu/cu2qu.py":170
  4148. * delta_3 = dt * delta_2
  4149. * for i in range(n):
  4150. * t1 = i * dt # <<<<<<<<<<<<<<
  4151. * t1_2 = t1 * t1
  4152. * # calc new a, b, c and d
  4153. */
  4154. __pyx_cur_scope->__pyx_v_t1 = (__pyx_cur_scope->__pyx_v_i * __pyx_cur_scope->__pyx_v_dt);
  4155. /* "fontTools/cu2qu/cu2qu.py":171
  4156. * for i in range(n):
  4157. * t1 = i * dt
  4158. * t1_2 = t1 * t1 # <<<<<<<<<<<<<<
  4159. * # calc new a, b, c and d
  4160. * a1 = a * delta_3
  4161. */
  4162. __pyx_cur_scope->__pyx_v_t1_2 = (__pyx_cur_scope->__pyx_v_t1 * __pyx_cur_scope->__pyx_v_t1);
  4163. /* "fontTools/cu2qu/cu2qu.py":173
  4164. * t1_2 = t1 * t1
  4165. * # calc new a, b, c and d
  4166. * a1 = a * delta_3 # <<<<<<<<<<<<<<
  4167. * b1 = (3 * a * t1 + b) * delta_2
  4168. * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt
  4169. */
  4170. __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));
  4171. /* "fontTools/cu2qu/cu2qu.py":174
  4172. * # calc new a, b, c and d
  4173. * a1 = a * delta_3
  4174. * b1 = (3 * a * t1 + b) * delta_2 # <<<<<<<<<<<<<<
  4175. * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt
  4176. * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d
  4177. */
  4178. __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));
  4179. /* "fontTools/cu2qu/cu2qu.py":175
  4180. * a1 = a * delta_3
  4181. * b1 = (3 * a * t1 + b) * delta_2
  4182. * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt # <<<<<<<<<<<<<<
  4183. * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d
  4184. * yield calc_cubic_points(a1, b1, c1, d1)
  4185. */
  4186. __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));
  4187. /* "fontTools/cu2qu/cu2qu.py":176
  4188. * b1 = (3 * a * t1 + b) * delta_2
  4189. * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt
  4190. * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d # <<<<<<<<<<<<<<
  4191. * yield calc_cubic_points(a1, b1, c1, d1)
  4192. *
  4193. */
  4194. __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);
  4195. /* "fontTools/cu2qu/cu2qu.py":177
  4196. * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt
  4197. * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d
  4198. * yield calc_cubic_points(a1, b1, c1, d1) # <<<<<<<<<<<<<<
  4199. *
  4200. *
  4201. */
  4202. __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)
  4203. __Pyx_GOTREF(__pyx_t_1);
  4204. __pyx_r = __pyx_t_1;
  4205. __pyx_t_1 = 0;
  4206. __pyx_cur_scope->__pyx_t_0 = __pyx_t_12;
  4207. __pyx_cur_scope->__pyx_t_1 = __pyx_t_13;
  4208. __pyx_cur_scope->__pyx_t_2 = __pyx_t_14;
  4209. __Pyx_XGIVEREF(__pyx_r);
  4210. __Pyx_RefNannyFinishContext();
  4211. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  4212. /* return from generator, yielding value */
  4213. __pyx_generator->resume_label = 1;
  4214. return __pyx_r;
  4215. __pyx_L8_resume_from_yield:;
  4216. __pyx_t_12 = __pyx_cur_scope->__pyx_t_0;
  4217. __pyx_t_13 = __pyx_cur_scope->__pyx_t_1;
  4218. __pyx_t_14 = __pyx_cur_scope->__pyx_t_2;
  4219. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 177, __pyx_L1_error)
  4220. }
  4221. CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
  4222. /* "fontTools/cu2qu/cu2qu.py":150
  4223. *
  4224. *
  4225. * @cython.locals( # <<<<<<<<<<<<<<
  4226. * p0=cython.complex,
  4227. * p1=cython.complex,
  4228. */
  4229. /* function exit code */
  4230. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4231. goto __pyx_L0;
  4232. __pyx_L1_error:;
  4233. __Pyx_XDECREF(__pyx_t_1);
  4234. __Pyx_XDECREF(__pyx_t_2);
  4235. __Pyx_XDECREF(__pyx_t_3);
  4236. __Pyx_XDECREF(__pyx_t_4);
  4237. __Pyx_XDECREF(__pyx_t_5);
  4238. __Pyx_XDECREF(__pyx_t_6);
  4239. if (__Pyx_PyErr_Occurred()) {
  4240. __Pyx_Generator_Replace_StopIteration(0);
  4241. __Pyx_AddTraceback("_split_cubic_into_n_gen", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4242. }
  4243. __pyx_L0:;
  4244. __Pyx_XGIVEREF(__pyx_r);
  4245. #if !CYTHON_USE_EXC_INFO_STACK
  4246. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  4247. #endif
  4248. __pyx_generator->resume_label = -1;
  4249. __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  4250. __Pyx_RefNannyFinishContext();
  4251. return __pyx_r;
  4252. }
  4253. /* "fontTools/cu2qu/cu2qu.py":180
  4254. *
  4255. *
  4256. * @cython.cfunc # <<<<<<<<<<<<<<
  4257. * @cython.inline
  4258. * @cython.locals(
  4259. */
  4260. 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) {
  4261. __pyx_t_double_complex __pyx_v_mid;
  4262. __pyx_t_double_complex __pyx_v_deriv3;
  4263. PyObject *__pyx_r = NULL;
  4264. __Pyx_RefNannyDeclarations
  4265. PyObject *__pyx_t_1 = NULL;
  4266. __pyx_t_double_complex __pyx_t_2;
  4267. PyObject *__pyx_t_3 = NULL;
  4268. PyObject *__pyx_t_4 = NULL;
  4269. PyObject *__pyx_t_5 = NULL;
  4270. PyObject *__pyx_t_6 = NULL;
  4271. PyObject *__pyx_t_7 = NULL;
  4272. int __pyx_lineno = 0;
  4273. const char *__pyx_filename = NULL;
  4274. int __pyx_clineno = 0;
  4275. __Pyx_RefNannySetupContext("split_cubic_into_two", 0);
  4276. /* "fontTools/cu2qu/cu2qu.py":201
  4277. * values).
  4278. * """
  4279. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 # <<<<<<<<<<<<<<
  4280. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  4281. * return (
  4282. */
  4283. __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));
  4284. /* "fontTools/cu2qu/cu2qu.py":202
  4285. * """
  4286. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  4287. * deriv3 = (p3 + p2 - p1 - p0) * 0.125 # <<<<<<<<<<<<<<
  4288. * return (
  4289. * (p0, (p0 + p1) * 0.5, mid - deriv3, mid),
  4290. */
  4291. __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));
  4292. /* "fontTools/cu2qu/cu2qu.py":203
  4293. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  4294. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  4295. * return ( # <<<<<<<<<<<<<<
  4296. * (p0, (p0 + p1) * 0.5, mid - deriv3, mid),
  4297. * (mid, mid + deriv3, (p2 + p3) * 0.5, p3),
  4298. */
  4299. __Pyx_XDECREF(__pyx_r);
  4300. /* "fontTools/cu2qu/cu2qu.py":204
  4301. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  4302. * return (
  4303. * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), # <<<<<<<<<<<<<<
  4304. * (mid, mid + deriv3, (p2 + p3) * 0.5, p3),
  4305. * )
  4306. */
  4307. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
  4308. __Pyx_GOTREF(__pyx_t_1);
  4309. __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));
  4310. __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
  4311. __Pyx_GOTREF(__pyx_t_3);
  4312. __pyx_t_2 = __Pyx_c_diff_double(__pyx_v_mid, __pyx_v_deriv3);
  4313. __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 204, __pyx_L1_error)
  4314. __Pyx_GOTREF(__pyx_t_4);
  4315. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_mid); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 204, __pyx_L1_error)
  4316. __Pyx_GOTREF(__pyx_t_5);
  4317. __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 204, __pyx_L1_error)
  4318. __Pyx_GOTREF(__pyx_t_6);
  4319. __Pyx_GIVEREF(__pyx_t_1);
  4320. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 204, __pyx_L1_error);
  4321. __Pyx_GIVEREF(__pyx_t_3);
  4322. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3) != (0)) __PYX_ERR(0, 204, __pyx_L1_error);
  4323. __Pyx_GIVEREF(__pyx_t_4);
  4324. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4) != (0)) __PYX_ERR(0, 204, __pyx_L1_error);
  4325. __Pyx_GIVEREF(__pyx_t_5);
  4326. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5) != (0)) __PYX_ERR(0, 204, __pyx_L1_error);
  4327. __pyx_t_1 = 0;
  4328. __pyx_t_3 = 0;
  4329. __pyx_t_4 = 0;
  4330. __pyx_t_5 = 0;
  4331. /* "fontTools/cu2qu/cu2qu.py":205
  4332. * return (
  4333. * (p0, (p0 + p1) * 0.5, mid - deriv3, mid),
  4334. * (mid, mid + deriv3, (p2 + p3) * 0.5, p3), # <<<<<<<<<<<<<<
  4335. * )
  4336. *
  4337. */
  4338. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_mid); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 205, __pyx_L1_error)
  4339. __Pyx_GOTREF(__pyx_t_5);
  4340. __pyx_t_2 = __Pyx_c_sum_double(__pyx_v_mid, __pyx_v_deriv3);
  4341. __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 205, __pyx_L1_error)
  4342. __Pyx_GOTREF(__pyx_t_4);
  4343. __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));
  4344. __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 205, __pyx_L1_error)
  4345. __Pyx_GOTREF(__pyx_t_3);
  4346. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error)
  4347. __Pyx_GOTREF(__pyx_t_1);
  4348. __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 205, __pyx_L1_error)
  4349. __Pyx_GOTREF(__pyx_t_7);
  4350. __Pyx_GIVEREF(__pyx_t_5);
  4351. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5) != (0)) __PYX_ERR(0, 205, __pyx_L1_error);
  4352. __Pyx_GIVEREF(__pyx_t_4);
  4353. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4) != (0)) __PYX_ERR(0, 205, __pyx_L1_error);
  4354. __Pyx_GIVEREF(__pyx_t_3);
  4355. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 205, __pyx_L1_error);
  4356. __Pyx_GIVEREF(__pyx_t_1);
  4357. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_1) != (0)) __PYX_ERR(0, 205, __pyx_L1_error);
  4358. __pyx_t_5 = 0;
  4359. __pyx_t_4 = 0;
  4360. __pyx_t_3 = 0;
  4361. __pyx_t_1 = 0;
  4362. /* "fontTools/cu2qu/cu2qu.py":204
  4363. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  4364. * return (
  4365. * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), # <<<<<<<<<<<<<<
  4366. * (mid, mid + deriv3, (p2 + p3) * 0.5, p3),
  4367. * )
  4368. */
  4369. __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
  4370. __Pyx_GOTREF(__pyx_t_1);
  4371. __Pyx_GIVEREF(__pyx_t_6);
  4372. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6) != (0)) __PYX_ERR(0, 204, __pyx_L1_error);
  4373. __Pyx_GIVEREF(__pyx_t_7);
  4374. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7) != (0)) __PYX_ERR(0, 204, __pyx_L1_error);
  4375. __pyx_t_6 = 0;
  4376. __pyx_t_7 = 0;
  4377. __pyx_r = __pyx_t_1;
  4378. __pyx_t_1 = 0;
  4379. goto __pyx_L0;
  4380. /* "fontTools/cu2qu/cu2qu.py":180
  4381. *
  4382. *
  4383. * @cython.cfunc # <<<<<<<<<<<<<<
  4384. * @cython.inline
  4385. * @cython.locals(
  4386. */
  4387. /* function exit code */
  4388. __pyx_L1_error:;
  4389. __Pyx_XDECREF(__pyx_t_1);
  4390. __Pyx_XDECREF(__pyx_t_3);
  4391. __Pyx_XDECREF(__pyx_t_4);
  4392. __Pyx_XDECREF(__pyx_t_5);
  4393. __Pyx_XDECREF(__pyx_t_6);
  4394. __Pyx_XDECREF(__pyx_t_7);
  4395. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.split_cubic_into_two", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4396. __pyx_r = 0;
  4397. __pyx_L0:;
  4398. __Pyx_XGIVEREF(__pyx_r);
  4399. __Pyx_RefNannyFinishContext();
  4400. return __pyx_r;
  4401. }
  4402. /* "fontTools/cu2qu/cu2qu.py":209
  4403. *
  4404. *
  4405. * @cython.cfunc # <<<<<<<<<<<<<<
  4406. * @cython.inline
  4407. * @cython.locals(
  4408. */
  4409. 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) {
  4410. __pyx_t_double_complex __pyx_v_mid1;
  4411. __pyx_t_double_complex __pyx_v_deriv1;
  4412. __pyx_t_double_complex __pyx_v_mid2;
  4413. __pyx_t_double_complex __pyx_v_deriv2;
  4414. PyObject *__pyx_r = NULL;
  4415. __Pyx_RefNannyDeclarations
  4416. PyObject *__pyx_t_1 = NULL;
  4417. __pyx_t_double_complex __pyx_t_2;
  4418. __pyx_t_double_complex __pyx_t_3;
  4419. __pyx_t_double_complex __pyx_t_4;
  4420. PyObject *__pyx_t_5 = NULL;
  4421. PyObject *__pyx_t_6 = NULL;
  4422. PyObject *__pyx_t_7 = NULL;
  4423. PyObject *__pyx_t_8 = NULL;
  4424. PyObject *__pyx_t_9 = NULL;
  4425. PyObject *__pyx_t_10 = NULL;
  4426. int __pyx_lineno = 0;
  4427. const char *__pyx_filename = NULL;
  4428. int __pyx_clineno = 0;
  4429. __Pyx_RefNannySetupContext("split_cubic_into_three", 0);
  4430. /* "fontTools/cu2qu/cu2qu.py":238
  4431. * values).
  4432. * """
  4433. * mid1 = (8 * p0 + 12 * p1 + 6 * p2 + p3) * (1 / 27) # <<<<<<<<<<<<<<
  4434. * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27)
  4435. * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27)
  4436. */
  4437. __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));
  4438. /* "fontTools/cu2qu/cu2qu.py":239
  4439. * """
  4440. * mid1 = (8 * p0 + 12 * p1 + 6 * p2 + p3) * (1 / 27)
  4441. * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27) # <<<<<<<<<<<<<<
  4442. * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27)
  4443. * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27)
  4444. */
  4445. __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));
  4446. /* "fontTools/cu2qu/cu2qu.py":240
  4447. * mid1 = (8 * p0 + 12 * p1 + 6 * p2 + p3) * (1 / 27)
  4448. * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27)
  4449. * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27) # <<<<<<<<<<<<<<
  4450. * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27)
  4451. * return (
  4452. */
  4453. __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));
  4454. /* "fontTools/cu2qu/cu2qu.py":241
  4455. * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27)
  4456. * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27)
  4457. * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) # <<<<<<<<<<<<<<
  4458. * return (
  4459. * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1),
  4460. */
  4461. __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));
  4462. /* "fontTools/cu2qu/cu2qu.py":242
  4463. * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27)
  4464. * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27)
  4465. * return ( # <<<<<<<<<<<<<<
  4466. * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1),
  4467. * (mid1, mid1 + deriv1, mid2 - deriv2, mid2),
  4468. */
  4469. __Pyx_XDECREF(__pyx_r);
  4470. /* "fontTools/cu2qu/cu2qu.py":243
  4471. * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27)
  4472. * return (
  4473. * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), # <<<<<<<<<<<<<<
  4474. * (mid1, mid1 + deriv1, mid2 - deriv2, mid2),
  4475. * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3),
  4476. */
  4477. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error)
  4478. __Pyx_GOTREF(__pyx_t_1);
  4479. __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);
  4480. __pyx_t_3 = __pyx_t_double_complex_from_parts(3.0, 0);
  4481. if (unlikely(__Pyx_c_is_zero_double(__pyx_t_3))) {
  4482. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  4483. __PYX_ERR(0, 243, __pyx_L1_error)
  4484. }
  4485. __pyx_t_4 = __Pyx_c_quot_double(__pyx_t_2, __pyx_t_3);
  4486. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 243, __pyx_L1_error)
  4487. __Pyx_GOTREF(__pyx_t_5);
  4488. __pyx_t_4 = __Pyx_c_diff_double(__pyx_v_mid1, __pyx_v_deriv1);
  4489. __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 243, __pyx_L1_error)
  4490. __Pyx_GOTREF(__pyx_t_6);
  4491. __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_mid1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 243, __pyx_L1_error)
  4492. __Pyx_GOTREF(__pyx_t_7);
  4493. __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 243, __pyx_L1_error)
  4494. __Pyx_GOTREF(__pyx_t_8);
  4495. __Pyx_GIVEREF(__pyx_t_1);
  4496. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4497. __Pyx_GIVEREF(__pyx_t_5);
  4498. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4499. __Pyx_GIVEREF(__pyx_t_6);
  4500. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_6) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4501. __Pyx_GIVEREF(__pyx_t_7);
  4502. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4503. __pyx_t_1 = 0;
  4504. __pyx_t_5 = 0;
  4505. __pyx_t_6 = 0;
  4506. __pyx_t_7 = 0;
  4507. /* "fontTools/cu2qu/cu2qu.py":244
  4508. * return (
  4509. * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1),
  4510. * (mid1, mid1 + deriv1, mid2 - deriv2, mid2), # <<<<<<<<<<<<<<
  4511. * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3),
  4512. * )
  4513. */
  4514. __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_mid1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 244, __pyx_L1_error)
  4515. __Pyx_GOTREF(__pyx_t_7);
  4516. __pyx_t_4 = __Pyx_c_sum_double(__pyx_v_mid1, __pyx_v_deriv1);
  4517. __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 244, __pyx_L1_error)
  4518. __Pyx_GOTREF(__pyx_t_6);
  4519. __pyx_t_4 = __Pyx_c_diff_double(__pyx_v_mid2, __pyx_v_deriv2);
  4520. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 244, __pyx_L1_error)
  4521. __Pyx_GOTREF(__pyx_t_5);
  4522. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_mid2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error)
  4523. __Pyx_GOTREF(__pyx_t_1);
  4524. __pyx_t_9 = PyTuple_New(4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 244, __pyx_L1_error)
  4525. __Pyx_GOTREF(__pyx_t_9);
  4526. __Pyx_GIVEREF(__pyx_t_7);
  4527. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7) != (0)) __PYX_ERR(0, 244, __pyx_L1_error);
  4528. __Pyx_GIVEREF(__pyx_t_6);
  4529. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_6) != (0)) __PYX_ERR(0, 244, __pyx_L1_error);
  4530. __Pyx_GIVEREF(__pyx_t_5);
  4531. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_5) != (0)) __PYX_ERR(0, 244, __pyx_L1_error);
  4532. __Pyx_GIVEREF(__pyx_t_1);
  4533. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_1) != (0)) __PYX_ERR(0, 244, __pyx_L1_error);
  4534. __pyx_t_7 = 0;
  4535. __pyx_t_6 = 0;
  4536. __pyx_t_5 = 0;
  4537. __pyx_t_1 = 0;
  4538. /* "fontTools/cu2qu/cu2qu.py":245
  4539. * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1),
  4540. * (mid1, mid1 + deriv1, mid2 - deriv2, mid2),
  4541. * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3), # <<<<<<<<<<<<<<
  4542. * )
  4543. *
  4544. */
  4545. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_mid2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error)
  4546. __Pyx_GOTREF(__pyx_t_1);
  4547. __pyx_t_4 = __Pyx_c_sum_double(__pyx_v_mid2, __pyx_v_deriv2);
  4548. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 245, __pyx_L1_error)
  4549. __Pyx_GOTREF(__pyx_t_5);
  4550. __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));
  4551. __pyx_t_3 = __pyx_t_double_complex_from_parts(3.0, 0);
  4552. if (unlikely(__Pyx_c_is_zero_double(__pyx_t_3))) {
  4553. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  4554. __PYX_ERR(0, 245, __pyx_L1_error)
  4555. }
  4556. __pyx_t_2 = __Pyx_c_quot_double(__pyx_t_4, __pyx_t_3);
  4557. __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 245, __pyx_L1_error)
  4558. __Pyx_GOTREF(__pyx_t_6);
  4559. __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 245, __pyx_L1_error)
  4560. __Pyx_GOTREF(__pyx_t_7);
  4561. __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 245, __pyx_L1_error)
  4562. __Pyx_GOTREF(__pyx_t_10);
  4563. __Pyx_GIVEREF(__pyx_t_1);
  4564. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 245, __pyx_L1_error);
  4565. __Pyx_GIVEREF(__pyx_t_5);
  4566. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 245, __pyx_L1_error);
  4567. __Pyx_GIVEREF(__pyx_t_6);
  4568. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_6) != (0)) __PYX_ERR(0, 245, __pyx_L1_error);
  4569. __Pyx_GIVEREF(__pyx_t_7);
  4570. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_7) != (0)) __PYX_ERR(0, 245, __pyx_L1_error);
  4571. __pyx_t_1 = 0;
  4572. __pyx_t_5 = 0;
  4573. __pyx_t_6 = 0;
  4574. __pyx_t_7 = 0;
  4575. /* "fontTools/cu2qu/cu2qu.py":243
  4576. * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27)
  4577. * return (
  4578. * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), # <<<<<<<<<<<<<<
  4579. * (mid1, mid1 + deriv1, mid2 - deriv2, mid2),
  4580. * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3),
  4581. */
  4582. __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 243, __pyx_L1_error)
  4583. __Pyx_GOTREF(__pyx_t_7);
  4584. __Pyx_GIVEREF(__pyx_t_8);
  4585. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4586. __Pyx_GIVEREF(__pyx_t_9);
  4587. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4588. __Pyx_GIVEREF(__pyx_t_10);
  4589. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_10) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4590. __pyx_t_8 = 0;
  4591. __pyx_t_9 = 0;
  4592. __pyx_t_10 = 0;
  4593. __pyx_r = __pyx_t_7;
  4594. __pyx_t_7 = 0;
  4595. goto __pyx_L0;
  4596. /* "fontTools/cu2qu/cu2qu.py":209
  4597. *
  4598. *
  4599. * @cython.cfunc # <<<<<<<<<<<<<<
  4600. * @cython.inline
  4601. * @cython.locals(
  4602. */
  4603. /* function exit code */
  4604. __pyx_L1_error:;
  4605. __Pyx_XDECREF(__pyx_t_1);
  4606. __Pyx_XDECREF(__pyx_t_5);
  4607. __Pyx_XDECREF(__pyx_t_6);
  4608. __Pyx_XDECREF(__pyx_t_7);
  4609. __Pyx_XDECREF(__pyx_t_8);
  4610. __Pyx_XDECREF(__pyx_t_9);
  4611. __Pyx_XDECREF(__pyx_t_10);
  4612. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.split_cubic_into_three", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4613. __pyx_r = 0;
  4614. __pyx_L0:;
  4615. __Pyx_XGIVEREF(__pyx_r);
  4616. __Pyx_RefNannyFinishContext();
  4617. return __pyx_r;
  4618. }
  4619. /* "fontTools/cu2qu/cu2qu.py":249
  4620. *
  4621. *
  4622. * @cython.cfunc # <<<<<<<<<<<<<<
  4623. * @cython.inline
  4624. * @cython.returns(cython.complex)
  4625. */
  4626. 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) {
  4627. __pyx_t_double_complex __pyx_v__p1;
  4628. __pyx_t_double_complex __pyx_v__p2;
  4629. __pyx_t_double_complex __pyx_r;
  4630. /* "fontTools/cu2qu/cu2qu.py":273
  4631. * complex: Location of candidate control point on quadratic curve.
  4632. * """
  4633. * _p1 = p0 + (p1 - p0) * 1.5 # <<<<<<<<<<<<<<
  4634. * _p2 = p3 + (p2 - p3) * 1.5
  4635. * return _p1 + (_p2 - _p1) * t
  4636. */
  4637. __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)));
  4638. /* "fontTools/cu2qu/cu2qu.py":274
  4639. * """
  4640. * _p1 = p0 + (p1 - p0) * 1.5
  4641. * _p2 = p3 + (p2 - p3) * 1.5 # <<<<<<<<<<<<<<
  4642. * return _p1 + (_p2 - _p1) * t
  4643. *
  4644. */
  4645. __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)));
  4646. /* "fontTools/cu2qu/cu2qu.py":275
  4647. * _p1 = p0 + (p1 - p0) * 1.5
  4648. * _p2 = p3 + (p2 - p3) * 1.5
  4649. * return _p1 + (_p2 - _p1) * t # <<<<<<<<<<<<<<
  4650. *
  4651. *
  4652. */
  4653. __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)));
  4654. goto __pyx_L0;
  4655. /* "fontTools/cu2qu/cu2qu.py":249
  4656. *
  4657. *
  4658. * @cython.cfunc # <<<<<<<<<<<<<<
  4659. * @cython.inline
  4660. * @cython.returns(cython.complex)
  4661. */
  4662. /* function exit code */
  4663. __pyx_L0:;
  4664. return __pyx_r;
  4665. }
  4666. /* "fontTools/cu2qu/cu2qu.py":278
  4667. *
  4668. *
  4669. * @cython.cfunc # <<<<<<<<<<<<<<
  4670. * @cython.inline
  4671. * @cython.returns(cython.complex)
  4672. */
  4673. 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) {
  4674. __pyx_t_double_complex __pyx_v_ab;
  4675. __pyx_t_double_complex __pyx_v_cd;
  4676. __pyx_t_double_complex __pyx_v_p;
  4677. double __pyx_v_h;
  4678. __pyx_t_double_complex __pyx_r;
  4679. __Pyx_RefNannyDeclarations
  4680. PyObject *__pyx_t_1 = NULL;
  4681. PyObject *__pyx_t_2 = NULL;
  4682. PyObject *__pyx_t_3 = NULL;
  4683. double __pyx_t_4;
  4684. double __pyx_t_5;
  4685. int __pyx_t_6;
  4686. PyObject *__pyx_t_7 = NULL;
  4687. PyObject *__pyx_t_8 = NULL;
  4688. PyObject *__pyx_t_9 = NULL;
  4689. int __pyx_t_10;
  4690. int __pyx_t_11;
  4691. PyObject *__pyx_t_12 = NULL;
  4692. PyObject *__pyx_t_13 = NULL;
  4693. PyObject *__pyx_t_14 = NULL;
  4694. PyObject *__pyx_t_15 = NULL;
  4695. size_t __pyx_t_16;
  4696. __pyx_t_double_complex __pyx_t_17;
  4697. int __pyx_lineno = 0;
  4698. const char *__pyx_filename = NULL;
  4699. int __pyx_clineno = 0;
  4700. __Pyx_RefNannySetupContext("calc_intersect", 0);
  4701. /* "fontTools/cu2qu/cu2qu.py":296
  4702. * if no intersection was found.
  4703. * """
  4704. * ab = b - a # <<<<<<<<<<<<<<
  4705. * cd = d - c
  4706. * p = ab * 1j
  4707. */
  4708. __pyx_v_ab = __Pyx_c_diff_double(__pyx_v_b, __pyx_v_a);
  4709. /* "fontTools/cu2qu/cu2qu.py":297
  4710. * """
  4711. * ab = b - a
  4712. * cd = d - c # <<<<<<<<<<<<<<
  4713. * p = ab * 1j
  4714. * try:
  4715. */
  4716. __pyx_v_cd = __Pyx_c_diff_double(__pyx_v_d, __pyx_v_c);
  4717. /* "fontTools/cu2qu/cu2qu.py":298
  4718. * ab = b - a
  4719. * cd = d - c
  4720. * p = ab * 1j # <<<<<<<<<<<<<<
  4721. * try:
  4722. * h = dot(p, a - c) / dot(p, cd)
  4723. */
  4724. __pyx_v_p = __Pyx_c_prod_double(__pyx_v_ab, __pyx_t_double_complex_from_parts(0, 1.0));
  4725. /* "fontTools/cu2qu/cu2qu.py":299
  4726. * cd = d - c
  4727. * p = ab * 1j
  4728. * try: # <<<<<<<<<<<<<<
  4729. * h = dot(p, a - c) / dot(p, cd)
  4730. * except ZeroDivisionError:
  4731. */
  4732. {
  4733. __Pyx_PyThreadState_declare
  4734. __Pyx_PyThreadState_assign
  4735. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  4736. __Pyx_XGOTREF(__pyx_t_1);
  4737. __Pyx_XGOTREF(__pyx_t_2);
  4738. __Pyx_XGOTREF(__pyx_t_3);
  4739. /*try:*/ {
  4740. /* "fontTools/cu2qu/cu2qu.py":300
  4741. * p = ab * 1j
  4742. * try:
  4743. * h = dot(p, a - c) / dot(p, cd) # <<<<<<<<<<<<<<
  4744. * except ZeroDivisionError:
  4745. * # if 3 or 4 points are equal, we do have an intersection despite the zero-div:
  4746. */
  4747. __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)
  4748. __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)
  4749. if (unlikely(__pyx_t_5 == 0)) {
  4750. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  4751. __PYX_ERR(0, 300, __pyx_L3_error)
  4752. }
  4753. __pyx_v_h = (__pyx_t_4 / __pyx_t_5);
  4754. /* "fontTools/cu2qu/cu2qu.py":299
  4755. * cd = d - c
  4756. * p = ab * 1j
  4757. * try: # <<<<<<<<<<<<<<
  4758. * h = dot(p, a - c) / dot(p, cd)
  4759. * except ZeroDivisionError:
  4760. */
  4761. }
  4762. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4763. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  4764. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  4765. goto __pyx_L8_try_end;
  4766. __pyx_L3_error:;
  4767. /* "fontTools/cu2qu/cu2qu.py":301
  4768. * try:
  4769. * h = dot(p, a - c) / dot(p, cd)
  4770. * except ZeroDivisionError: # <<<<<<<<<<<<<<
  4771. * # if 3 or 4 points are equal, we do have an intersection despite the zero-div:
  4772. * # return one of the off-curves so that the algorithm can attempt a one-curve
  4773. */
  4774. __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_ZeroDivisionError))));
  4775. if (__pyx_t_6) {
  4776. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_intersect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4777. if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 301, __pyx_L5_except_error)
  4778. __Pyx_XGOTREF(__pyx_t_7);
  4779. __Pyx_XGOTREF(__pyx_t_8);
  4780. __Pyx_XGOTREF(__pyx_t_9);
  4781. /* "fontTools/cu2qu/cu2qu.py":306
  4782. * # solution if it's within tolerance:
  4783. * # https://github.com/linebender/kurbo/pull/484
  4784. * if b == c and (a == b or c == d): # <<<<<<<<<<<<<<
  4785. * return b
  4786. * return complex(NAN, NAN)
  4787. */
  4788. __pyx_t_11 = (__Pyx_c_eq_double(__pyx_v_b, __pyx_v_c));
  4789. if (__pyx_t_11) {
  4790. } else {
  4791. __pyx_t_10 = __pyx_t_11;
  4792. goto __pyx_L12_bool_binop_done;
  4793. }
  4794. __pyx_t_11 = (__Pyx_c_eq_double(__pyx_v_a, __pyx_v_b));
  4795. if (!__pyx_t_11) {
  4796. } else {
  4797. __pyx_t_10 = __pyx_t_11;
  4798. goto __pyx_L12_bool_binop_done;
  4799. }
  4800. __pyx_t_11 = (__Pyx_c_eq_double(__pyx_v_c, __pyx_v_d));
  4801. __pyx_t_10 = __pyx_t_11;
  4802. __pyx_L12_bool_binop_done:;
  4803. if (__pyx_t_10) {
  4804. /* "fontTools/cu2qu/cu2qu.py":307
  4805. * # https://github.com/linebender/kurbo/pull/484
  4806. * if b == c and (a == b or c == d):
  4807. * return b # <<<<<<<<<<<<<<
  4808. * return complex(NAN, NAN)
  4809. * return c + cd * h
  4810. */
  4811. __pyx_r = __pyx_v_b;
  4812. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4813. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4814. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4815. goto __pyx_L6_except_return;
  4816. /* "fontTools/cu2qu/cu2qu.py":306
  4817. * # solution if it's within tolerance:
  4818. * # https://github.com/linebender/kurbo/pull/484
  4819. * if b == c and (a == b or c == d): # <<<<<<<<<<<<<<
  4820. * return b
  4821. * return complex(NAN, NAN)
  4822. */
  4823. }
  4824. /* "fontTools/cu2qu/cu2qu.py":308
  4825. * if b == c and (a == b or c == d):
  4826. * return b
  4827. * return complex(NAN, NAN) # <<<<<<<<<<<<<<
  4828. * return c + cd * h
  4829. *
  4830. */
  4831. __pyx_t_13 = NULL;
  4832. __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)
  4833. __Pyx_GOTREF(__pyx_t_14);
  4834. __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)
  4835. __Pyx_GOTREF(__pyx_t_15);
  4836. __pyx_t_16 = 1;
  4837. {
  4838. PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_t_14, __pyx_t_15};
  4839. __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));
  4840. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  4841. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  4842. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4843. if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 308, __pyx_L5_except_error)
  4844. __Pyx_GOTREF(__pyx_t_12);
  4845. }
  4846. __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)
  4847. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4848. __pyx_r = __pyx_t_17;
  4849. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4850. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4851. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4852. goto __pyx_L6_except_return;
  4853. }
  4854. goto __pyx_L5_except_error;
  4855. /* "fontTools/cu2qu/cu2qu.py":299
  4856. * cd = d - c
  4857. * p = ab * 1j
  4858. * try: # <<<<<<<<<<<<<<
  4859. * h = dot(p, a - c) / dot(p, cd)
  4860. * except ZeroDivisionError:
  4861. */
  4862. __pyx_L5_except_error:;
  4863. __Pyx_XGIVEREF(__pyx_t_1);
  4864. __Pyx_XGIVEREF(__pyx_t_2);
  4865. __Pyx_XGIVEREF(__pyx_t_3);
  4866. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  4867. goto __pyx_L1_error;
  4868. __pyx_L6_except_return:;
  4869. __Pyx_XGIVEREF(__pyx_t_1);
  4870. __Pyx_XGIVEREF(__pyx_t_2);
  4871. __Pyx_XGIVEREF(__pyx_t_3);
  4872. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  4873. goto __pyx_L0;
  4874. __pyx_L8_try_end:;
  4875. }
  4876. /* "fontTools/cu2qu/cu2qu.py":309
  4877. * return b
  4878. * return complex(NAN, NAN)
  4879. * return c + cd * h # <<<<<<<<<<<<<<
  4880. *
  4881. *
  4882. */
  4883. __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)));
  4884. goto __pyx_L0;
  4885. /* "fontTools/cu2qu/cu2qu.py":278
  4886. *
  4887. *
  4888. * @cython.cfunc # <<<<<<<<<<<<<<
  4889. * @cython.inline
  4890. * @cython.returns(cython.complex)
  4891. */
  4892. /* function exit code */
  4893. __pyx_L1_error:;
  4894. __Pyx_XDECREF(__pyx_t_7);
  4895. __Pyx_XDECREF(__pyx_t_8);
  4896. __Pyx_XDECREF(__pyx_t_9);
  4897. __Pyx_XDECREF(__pyx_t_12);
  4898. __Pyx_XDECREF(__pyx_t_13);
  4899. __Pyx_XDECREF(__pyx_t_14);
  4900. __Pyx_XDECREF(__pyx_t_15);
  4901. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_intersect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4902. __pyx_r = __pyx_t_double_complex_from_parts(0, 0);
  4903. __pyx_L0:;
  4904. __Pyx_RefNannyFinishContext();
  4905. return __pyx_r;
  4906. }
  4907. /* "fontTools/cu2qu/cu2qu.py":312
  4908. *
  4909. *
  4910. * @cython.cfunc # <<<<<<<<<<<<<<
  4911. * @cython.returns(cython.int)
  4912. * @cython.locals(
  4913. */
  4914. 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) {
  4915. __pyx_t_double_complex __pyx_v_mid;
  4916. __pyx_t_double_complex __pyx_v_deriv3;
  4917. int __pyx_r;
  4918. int __pyx_t_1;
  4919. int __pyx_t_2;
  4920. int __pyx_t_3;
  4921. int __pyx_t_4;
  4922. int __pyx_lineno = 0;
  4923. const char *__pyx_filename = NULL;
  4924. int __pyx_clineno = 0;
  4925. /* "fontTools/cu2qu/cu2qu.py":341
  4926. * """
  4927. * # First check p2 then p1, as p2 has higher error early on.
  4928. * if abs(p2) <= tolerance and abs(p1) <= tolerance: # <<<<<<<<<<<<<<
  4929. * return True
  4930. *
  4931. */
  4932. __pyx_t_2 = (__Pyx_c_abs_double(__pyx_v_p2) <= __pyx_v_tolerance);
  4933. if (__pyx_t_2) {
  4934. } else {
  4935. __pyx_t_1 = __pyx_t_2;
  4936. goto __pyx_L4_bool_binop_done;
  4937. }
  4938. __pyx_t_2 = (__Pyx_c_abs_double(__pyx_v_p1) <= __pyx_v_tolerance);
  4939. __pyx_t_1 = __pyx_t_2;
  4940. __pyx_L4_bool_binop_done:;
  4941. if (__pyx_t_1) {
  4942. /* "fontTools/cu2qu/cu2qu.py":342
  4943. * # First check p2 then p1, as p2 has higher error early on.
  4944. * if abs(p2) <= tolerance and abs(p1) <= tolerance:
  4945. * return True # <<<<<<<<<<<<<<
  4946. *
  4947. * # Split.
  4948. */
  4949. __pyx_r = 1;
  4950. goto __pyx_L0;
  4951. /* "fontTools/cu2qu/cu2qu.py":341
  4952. * """
  4953. * # First check p2 then p1, as p2 has higher error early on.
  4954. * if abs(p2) <= tolerance and abs(p1) <= tolerance: # <<<<<<<<<<<<<<
  4955. * return True
  4956. *
  4957. */
  4958. }
  4959. /* "fontTools/cu2qu/cu2qu.py":345
  4960. *
  4961. * # Split.
  4962. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 # <<<<<<<<<<<<<<
  4963. * if abs(mid) > tolerance:
  4964. * return False
  4965. */
  4966. __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));
  4967. /* "fontTools/cu2qu/cu2qu.py":346
  4968. * # Split.
  4969. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  4970. * if abs(mid) > tolerance: # <<<<<<<<<<<<<<
  4971. * return False
  4972. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  4973. */
  4974. __pyx_t_1 = (__Pyx_c_abs_double(__pyx_v_mid) > __pyx_v_tolerance);
  4975. if (__pyx_t_1) {
  4976. /* "fontTools/cu2qu/cu2qu.py":347
  4977. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  4978. * if abs(mid) > tolerance:
  4979. * return False # <<<<<<<<<<<<<<
  4980. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  4981. * return cubic_farthest_fit_inside(
  4982. */
  4983. __pyx_r = 0;
  4984. goto __pyx_L0;
  4985. /* "fontTools/cu2qu/cu2qu.py":346
  4986. * # Split.
  4987. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  4988. * if abs(mid) > tolerance: # <<<<<<<<<<<<<<
  4989. * return False
  4990. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  4991. */
  4992. }
  4993. /* "fontTools/cu2qu/cu2qu.py":348
  4994. * if abs(mid) > tolerance:
  4995. * return False
  4996. * deriv3 = (p3 + p2 - p1 - p0) * 0.125 # <<<<<<<<<<<<<<
  4997. * return cubic_farthest_fit_inside(
  4998. * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance
  4999. */
  5000. __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));
  5001. /* "fontTools/cu2qu/cu2qu.py":349
  5002. * return False
  5003. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  5004. * return cubic_farthest_fit_inside( # <<<<<<<<<<<<<<
  5005. * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance
  5006. * ) and cubic_farthest_fit_inside(mid, mid + deriv3, (p2 + p3) * 0.5, p3, tolerance)
  5007. */
  5008. __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)
  5009. if (__pyx_t_4) {
  5010. } else {
  5011. __pyx_t_3 = __pyx_t_4;
  5012. goto __pyx_L7_bool_binop_done;
  5013. }
  5014. /* "fontTools/cu2qu/cu2qu.py":351
  5015. * return cubic_farthest_fit_inside(
  5016. * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance
  5017. * ) and cubic_farthest_fit_inside(mid, mid + deriv3, (p2 + p3) * 0.5, p3, tolerance) # <<<<<<<<<<<<<<
  5018. *
  5019. *
  5020. */
  5021. __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)
  5022. __pyx_t_3 = __pyx_t_4;
  5023. __pyx_L7_bool_binop_done:;
  5024. __pyx_r = __pyx_t_3;
  5025. goto __pyx_L0;
  5026. /* "fontTools/cu2qu/cu2qu.py":312
  5027. *
  5028. *
  5029. * @cython.cfunc # <<<<<<<<<<<<<<
  5030. * @cython.returns(cython.int)
  5031. * @cython.locals(
  5032. */
  5033. /* function exit code */
  5034. __pyx_L1_error:;
  5035. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.cubic_farthest_fit_inside", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5036. __pyx_r = -1;
  5037. __pyx_L0:;
  5038. return __pyx_r;
  5039. }
  5040. /* "fontTools/cu2qu/cu2qu.py":354
  5041. *
  5042. *
  5043. * @cython.cfunc # <<<<<<<<<<<<<<
  5044. * @cython.inline
  5045. * @cython.locals(tolerance=cython.double)
  5046. */
  5047. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_quadratic(PyObject *__pyx_v_cubic, double __pyx_v_tolerance) {
  5048. __pyx_t_double_complex __pyx_v_q1;
  5049. __pyx_t_double_complex __pyx_v_c0;
  5050. __pyx_t_double_complex __pyx_v_c1;
  5051. __pyx_t_double_complex __pyx_v_c2;
  5052. __pyx_t_double_complex __pyx_v_c3;
  5053. PyObject *__pyx_r = NULL;
  5054. __Pyx_RefNannyDeclarations
  5055. PyObject *__pyx_t_1 = NULL;
  5056. __pyx_t_double_complex __pyx_t_2;
  5057. __pyx_t_double_complex __pyx_t_3;
  5058. __pyx_t_double_complex __pyx_t_4;
  5059. __pyx_t_double_complex __pyx_t_5;
  5060. __pyx_t_double_complex __pyx_t_6;
  5061. PyObject *__pyx_t_7 = NULL;
  5062. PyObject *__pyx_t_8 = NULL;
  5063. PyObject *__pyx_t_9 = NULL;
  5064. size_t __pyx_t_10;
  5065. int __pyx_t_11;
  5066. int __pyx_t_12;
  5067. int __pyx_lineno = 0;
  5068. const char *__pyx_filename = NULL;
  5069. int __pyx_clineno = 0;
  5070. __Pyx_RefNannySetupContext("cubic_approx_quadratic", 0);
  5071. /* "fontTools/cu2qu/cu2qu.py":378
  5072. * """
  5073. *
  5074. * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3]) # <<<<<<<<<<<<<<
  5075. * if math.isnan(q1.imag):
  5076. * return None
  5077. */
  5078. __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)
  5079. __Pyx_GOTREF(__pyx_t_1);
  5080. __pyx_t_2 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L1_error)
  5081. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5082. __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)
  5083. __Pyx_GOTREF(__pyx_t_1);
  5084. __pyx_t_3 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L1_error)
  5085. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5086. __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)
  5087. __Pyx_GOTREF(__pyx_t_1);
  5088. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L1_error)
  5089. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5090. __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)
  5091. __Pyx_GOTREF(__pyx_t_1);
  5092. __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L1_error)
  5093. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5094. __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)
  5095. __pyx_v_q1 = __pyx_t_6;
  5096. /* "fontTools/cu2qu/cu2qu.py":379
  5097. *
  5098. * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3])
  5099. * if math.isnan(q1.imag): # <<<<<<<<<<<<<<
  5100. * return None
  5101. * c0 = cubic[0]
  5102. */
  5103. __pyx_t_7 = NULL;
  5104. __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_math); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 379, __pyx_L1_error)
  5105. __Pyx_GOTREF(__pyx_t_8);
  5106. __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)
  5107. __Pyx_GOTREF(__pyx_t_9);
  5108. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5109. __pyx_t_8 = PyFloat_FromDouble(__Pyx_CIMAG(__pyx_v_q1)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 379, __pyx_L1_error)
  5110. __Pyx_GOTREF(__pyx_t_8);
  5111. __pyx_t_10 = 1;
  5112. #if CYTHON_UNPACK_METHODS
  5113. if (unlikely(PyMethod_Check(__pyx_t_9))) {
  5114. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
  5115. assert(__pyx_t_7);
  5116. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
  5117. __Pyx_INCREF(__pyx_t_7);
  5118. __Pyx_INCREF(__pyx__function);
  5119. __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
  5120. __pyx_t_10 = 0;
  5121. }
  5122. #endif
  5123. {
  5124. PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_8};
  5125. __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));
  5126. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5127. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5128. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  5129. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 379, __pyx_L1_error)
  5130. __Pyx_GOTREF(__pyx_t_1);
  5131. }
  5132. __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 379, __pyx_L1_error)
  5133. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5134. if (__pyx_t_11) {
  5135. /* "fontTools/cu2qu/cu2qu.py":380
  5136. * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3])
  5137. * if math.isnan(q1.imag):
  5138. * return None # <<<<<<<<<<<<<<
  5139. * c0 = cubic[0]
  5140. * c3 = cubic[3]
  5141. */
  5142. __Pyx_XDECREF(__pyx_r);
  5143. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5144. goto __pyx_L0;
  5145. /* "fontTools/cu2qu/cu2qu.py":379
  5146. *
  5147. * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3])
  5148. * if math.isnan(q1.imag): # <<<<<<<<<<<<<<
  5149. * return None
  5150. * c0 = cubic[0]
  5151. */
  5152. }
  5153. /* "fontTools/cu2qu/cu2qu.py":381
  5154. * if math.isnan(q1.imag):
  5155. * return None
  5156. * c0 = cubic[0] # <<<<<<<<<<<<<<
  5157. * c3 = cubic[3]
  5158. * c1 = c0 + (q1 - c0) * (2 / 3)
  5159. */
  5160. __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)
  5161. __Pyx_GOTREF(__pyx_t_1);
  5162. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 381, __pyx_L1_error)
  5163. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5164. __pyx_v_c0 = __pyx_t_6;
  5165. /* "fontTools/cu2qu/cu2qu.py":382
  5166. * return None
  5167. * c0 = cubic[0]
  5168. * c3 = cubic[3] # <<<<<<<<<<<<<<
  5169. * c1 = c0 + (q1 - c0) * (2 / 3)
  5170. * c2 = c3 + (q1 - c3) * (2 / 3)
  5171. */
  5172. __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)
  5173. __Pyx_GOTREF(__pyx_t_1);
  5174. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 382, __pyx_L1_error)
  5175. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5176. __pyx_v_c3 = __pyx_t_6;
  5177. /* "fontTools/cu2qu/cu2qu.py":383
  5178. * c0 = cubic[0]
  5179. * c3 = cubic[3]
  5180. * c1 = c0 + (q1 - c0) * (2 / 3) # <<<<<<<<<<<<<<
  5181. * c2 = c3 + (q1 - c3) * (2 / 3)
  5182. * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance):
  5183. */
  5184. __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)));
  5185. /* "fontTools/cu2qu/cu2qu.py":384
  5186. * c3 = cubic[3]
  5187. * c1 = c0 + (q1 - c0) * (2 / 3)
  5188. * c2 = c3 + (q1 - c3) * (2 / 3) # <<<<<<<<<<<<<<
  5189. * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance):
  5190. * return None
  5191. */
  5192. __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)));
  5193. /* "fontTools/cu2qu/cu2qu.py":385
  5194. * c1 = c0 + (q1 - c0) * (2 / 3)
  5195. * c2 = c3 + (q1 - c3) * (2 / 3)
  5196. * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): # <<<<<<<<<<<<<<
  5197. * return None
  5198. * return c0, q1, c3
  5199. */
  5200. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_c1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error)
  5201. __Pyx_GOTREF(__pyx_t_1);
  5202. __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)
  5203. __Pyx_GOTREF(__pyx_t_9);
  5204. __pyx_t_8 = PyNumber_Subtract(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 385, __pyx_L1_error)
  5205. __Pyx_GOTREF(__pyx_t_8);
  5206. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5207. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  5208. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 385, __pyx_L1_error)
  5209. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5210. __pyx_t_8 = __pyx_PyComplex_FromComplex(__pyx_v_c2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 385, __pyx_L1_error)
  5211. __Pyx_GOTREF(__pyx_t_8);
  5212. __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)
  5213. __Pyx_GOTREF(__pyx_t_9);
  5214. __pyx_t_1 = PyNumber_Subtract(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error)
  5215. __Pyx_GOTREF(__pyx_t_1);
  5216. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5217. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  5218. __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 385, __pyx_L1_error)
  5219. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5220. __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)
  5221. __pyx_t_11 = (!(__pyx_t_12 != 0));
  5222. if (__pyx_t_11) {
  5223. /* "fontTools/cu2qu/cu2qu.py":386
  5224. * c2 = c3 + (q1 - c3) * (2 / 3)
  5225. * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance):
  5226. * return None # <<<<<<<<<<<<<<
  5227. * return c0, q1, c3
  5228. *
  5229. */
  5230. __Pyx_XDECREF(__pyx_r);
  5231. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5232. goto __pyx_L0;
  5233. /* "fontTools/cu2qu/cu2qu.py":385
  5234. * c1 = c0 + (q1 - c0) * (2 / 3)
  5235. * c2 = c3 + (q1 - c3) * (2 / 3)
  5236. * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): # <<<<<<<<<<<<<<
  5237. * return None
  5238. * return c0, q1, c3
  5239. */
  5240. }
  5241. /* "fontTools/cu2qu/cu2qu.py":387
  5242. * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance):
  5243. * return None
  5244. * return c0, q1, c3 # <<<<<<<<<<<<<<
  5245. *
  5246. *
  5247. */
  5248. __Pyx_XDECREF(__pyx_r);
  5249. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_c0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L1_error)
  5250. __Pyx_GOTREF(__pyx_t_1);
  5251. __pyx_t_9 = __pyx_PyComplex_FromComplex(__pyx_v_q1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 387, __pyx_L1_error)
  5252. __Pyx_GOTREF(__pyx_t_9);
  5253. __pyx_t_8 = __pyx_PyComplex_FromComplex(__pyx_v_c3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 387, __pyx_L1_error)
  5254. __Pyx_GOTREF(__pyx_t_8);
  5255. __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 387, __pyx_L1_error)
  5256. __Pyx_GOTREF(__pyx_t_7);
  5257. __Pyx_GIVEREF(__pyx_t_1);
  5258. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 387, __pyx_L1_error);
  5259. __Pyx_GIVEREF(__pyx_t_9);
  5260. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9) != (0)) __PYX_ERR(0, 387, __pyx_L1_error);
  5261. __Pyx_GIVEREF(__pyx_t_8);
  5262. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_8) != (0)) __PYX_ERR(0, 387, __pyx_L1_error);
  5263. __pyx_t_1 = 0;
  5264. __pyx_t_9 = 0;
  5265. __pyx_t_8 = 0;
  5266. __pyx_r = __pyx_t_7;
  5267. __pyx_t_7 = 0;
  5268. goto __pyx_L0;
  5269. /* "fontTools/cu2qu/cu2qu.py":354
  5270. *
  5271. *
  5272. * @cython.cfunc # <<<<<<<<<<<<<<
  5273. * @cython.inline
  5274. * @cython.locals(tolerance=cython.double)
  5275. */
  5276. /* function exit code */
  5277. __pyx_L1_error:;
  5278. __Pyx_XDECREF(__pyx_t_1);
  5279. __Pyx_XDECREF(__pyx_t_7);
  5280. __Pyx_XDECREF(__pyx_t_8);
  5281. __Pyx_XDECREF(__pyx_t_9);
  5282. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.cubic_approx_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5283. __pyx_r = 0;
  5284. __pyx_L0:;
  5285. __Pyx_XGIVEREF(__pyx_r);
  5286. __Pyx_RefNannyFinishContext();
  5287. return __pyx_r;
  5288. }
  5289. /* "fontTools/cu2qu/cu2qu.py":390
  5290. *
  5291. *
  5292. * @cython.cfunc # <<<<<<<<<<<<<<
  5293. * @cython.locals(n=cython.int, tolerance=cython.double)
  5294. * @cython.locals(i=cython.int)
  5295. */
  5296. 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) {
  5297. __pyx_t_double_complex __pyx_v_q0;
  5298. __pyx_t_double_complex __pyx_v_q1;
  5299. __pyx_t_double_complex __pyx_v_next_q1;
  5300. __pyx_t_double_complex __pyx_v_q2;
  5301. __pyx_t_double_complex __pyx_v_d1;
  5302. CYTHON_UNUSED __pyx_t_double_complex __pyx_v_c0;
  5303. __pyx_t_double_complex __pyx_v_c1;
  5304. __pyx_t_double_complex __pyx_v_c2;
  5305. __pyx_t_double_complex __pyx_v_c3;
  5306. int __pyx_v_i;
  5307. PyObject *__pyx_v_cubics = NULL;
  5308. PyObject *__pyx_v_next_cubic = NULL;
  5309. PyObject *__pyx_v_spline = NULL;
  5310. __pyx_t_double_complex __pyx_v_d0;
  5311. PyObject *__pyx_r = NULL;
  5312. __Pyx_RefNannyDeclarations
  5313. int __pyx_t_1;
  5314. PyObject *__pyx_t_2 = NULL;
  5315. int __pyx_t_3;
  5316. __pyx_t_double_complex __pyx_t_4;
  5317. __pyx_t_double_complex __pyx_t_5;
  5318. __pyx_t_double_complex __pyx_t_6;
  5319. __pyx_t_double_complex __pyx_t_7;
  5320. PyObject *__pyx_t_8 = NULL;
  5321. __pyx_t_double_complex __pyx_t_9;
  5322. PyObject *__pyx_t_10 = NULL;
  5323. long __pyx_t_11;
  5324. long __pyx_t_12;
  5325. int __pyx_t_13;
  5326. PyObject *__pyx_t_14 = NULL;
  5327. PyObject *__pyx_t_15 = NULL;
  5328. PyObject *(*__pyx_t_16)(PyObject *);
  5329. long __pyx_t_17;
  5330. int __pyx_t_18;
  5331. int __pyx_t_19;
  5332. int __pyx_lineno = 0;
  5333. const char *__pyx_filename = NULL;
  5334. int __pyx_clineno = 0;
  5335. __Pyx_RefNannySetupContext("cubic_approx_spline", 0);
  5336. /* "fontTools/cu2qu/cu2qu.py":419
  5337. * """
  5338. *
  5339. * if n == 1: # <<<<<<<<<<<<<<
  5340. * return cubic_approx_quadratic(cubic, tolerance)
  5341. * if n == 2 and all_quadratic == False:
  5342. */
  5343. __pyx_t_1 = (__pyx_v_n == 1);
  5344. if (__pyx_t_1) {
  5345. /* "fontTools/cu2qu/cu2qu.py":420
  5346. *
  5347. * if n == 1:
  5348. * return cubic_approx_quadratic(cubic, tolerance) # <<<<<<<<<<<<<<
  5349. * if n == 2 and all_quadratic == False:
  5350. * return cubic
  5351. */
  5352. __Pyx_XDECREF(__pyx_r);
  5353. __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)
  5354. __Pyx_GOTREF(__pyx_t_2);
  5355. __pyx_r = __pyx_t_2;
  5356. __pyx_t_2 = 0;
  5357. goto __pyx_L0;
  5358. /* "fontTools/cu2qu/cu2qu.py":419
  5359. * """
  5360. *
  5361. * if n == 1: # <<<<<<<<<<<<<<
  5362. * return cubic_approx_quadratic(cubic, tolerance)
  5363. * if n == 2 and all_quadratic == False:
  5364. */
  5365. }
  5366. /* "fontTools/cu2qu/cu2qu.py":421
  5367. * if n == 1:
  5368. * return cubic_approx_quadratic(cubic, tolerance)
  5369. * if n == 2 and all_quadratic == False: # <<<<<<<<<<<<<<
  5370. * return cubic
  5371. *
  5372. */
  5373. __pyx_t_3 = (__pyx_v_n == 2);
  5374. if (__pyx_t_3) {
  5375. } else {
  5376. __pyx_t_1 = __pyx_t_3;
  5377. goto __pyx_L5_bool_binop_done;
  5378. }
  5379. __pyx_t_3 = (__pyx_v_all_quadratic == 0);
  5380. __pyx_t_1 = __pyx_t_3;
  5381. __pyx_L5_bool_binop_done:;
  5382. if (__pyx_t_1) {
  5383. /* "fontTools/cu2qu/cu2qu.py":422
  5384. * return cubic_approx_quadratic(cubic, tolerance)
  5385. * if n == 2 and all_quadratic == False:
  5386. * return cubic # <<<<<<<<<<<<<<
  5387. *
  5388. * cubics = split_cubic_into_n_iter(cubic[0], cubic[1], cubic[2], cubic[3], n)
  5389. */
  5390. __Pyx_XDECREF(__pyx_r);
  5391. __Pyx_INCREF(__pyx_v_cubic);
  5392. __pyx_r = __pyx_v_cubic;
  5393. goto __pyx_L0;
  5394. /* "fontTools/cu2qu/cu2qu.py":421
  5395. * if n == 1:
  5396. * return cubic_approx_quadratic(cubic, tolerance)
  5397. * if n == 2 and all_quadratic == False: # <<<<<<<<<<<<<<
  5398. * return cubic
  5399. *
  5400. */
  5401. }
  5402. /* "fontTools/cu2qu/cu2qu.py":424
  5403. * return cubic
  5404. *
  5405. * cubics = split_cubic_into_n_iter(cubic[0], cubic[1], cubic[2], cubic[3], n) # <<<<<<<<<<<<<<
  5406. *
  5407. * # calculate the spline of quadratics and check errors at the same time.
  5408. */
  5409. __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)
  5410. __Pyx_GOTREF(__pyx_t_2);
  5411. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 424, __pyx_L1_error)
  5412. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5413. __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)
  5414. __Pyx_GOTREF(__pyx_t_2);
  5415. __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 424, __pyx_L1_error)
  5416. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5417. __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)
  5418. __Pyx_GOTREF(__pyx_t_2);
  5419. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 424, __pyx_L1_error)
  5420. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5421. __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)
  5422. __Pyx_GOTREF(__pyx_t_2);
  5423. __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 424, __pyx_L1_error)
  5424. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5425. __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 424, __pyx_L1_error)
  5426. __Pyx_GOTREF(__pyx_t_2);
  5427. __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)
  5428. __Pyx_GOTREF(__pyx_t_8);
  5429. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5430. __pyx_v_cubics = __pyx_t_8;
  5431. __pyx_t_8 = 0;
  5432. /* "fontTools/cu2qu/cu2qu.py":427
  5433. *
  5434. * # calculate the spline of quadratics and check errors at the same time.
  5435. * next_cubic = next(cubics) # <<<<<<<<<<<<<<
  5436. * next_q1 = cubic_approx_control(
  5437. * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3]
  5438. */
  5439. __pyx_t_8 = __Pyx_PyIter_Next(__pyx_v_cubics); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 427, __pyx_L1_error)
  5440. __Pyx_GOTREF(__pyx_t_8);
  5441. __pyx_v_next_cubic = __pyx_t_8;
  5442. __pyx_t_8 = 0;
  5443. /* "fontTools/cu2qu/cu2qu.py":429
  5444. * next_cubic = next(cubics)
  5445. * next_q1 = cubic_approx_control(
  5446. * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] # <<<<<<<<<<<<<<
  5447. * )
  5448. * q2 = cubic[0]
  5449. */
  5450. __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)
  5451. __Pyx_GOTREF(__pyx_t_8);
  5452. __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 429, __pyx_L1_error)
  5453. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5454. __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)
  5455. __Pyx_GOTREF(__pyx_t_8);
  5456. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 429, __pyx_L1_error)
  5457. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5458. __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)
  5459. __Pyx_GOTREF(__pyx_t_8);
  5460. __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 429, __pyx_L1_error)
  5461. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5462. __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)
  5463. __Pyx_GOTREF(__pyx_t_8);
  5464. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 429, __pyx_L1_error)
  5465. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5466. /* "fontTools/cu2qu/cu2qu.py":428
  5467. * # calculate the spline of quadratics and check errors at the same time.
  5468. * next_cubic = next(cubics)
  5469. * next_q1 = cubic_approx_control( # <<<<<<<<<<<<<<
  5470. * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3]
  5471. * )
  5472. */
  5473. __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)
  5474. __pyx_v_next_q1 = __pyx_t_9;
  5475. /* "fontTools/cu2qu/cu2qu.py":431
  5476. * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3]
  5477. * )
  5478. * q2 = cubic[0] # <<<<<<<<<<<<<<
  5479. * d1 = 0j
  5480. * spline = [cubic[0], next_q1]
  5481. */
  5482. __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)
  5483. __Pyx_GOTREF(__pyx_t_8);
  5484. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 431, __pyx_L1_error)
  5485. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5486. __pyx_v_q2 = __pyx_t_9;
  5487. /* "fontTools/cu2qu/cu2qu.py":432
  5488. * )
  5489. * q2 = cubic[0]
  5490. * d1 = 0j # <<<<<<<<<<<<<<
  5491. * spline = [cubic[0], next_q1]
  5492. * for i in range(1, n + 1):
  5493. */
  5494. __pyx_v_d1 = __pyx_t_double_complex_from_parts(0, 0.0);
  5495. /* "fontTools/cu2qu/cu2qu.py":433
  5496. * q2 = cubic[0]
  5497. * d1 = 0j
  5498. * spline = [cubic[0], next_q1] # <<<<<<<<<<<<<<
  5499. * for i in range(1, n + 1):
  5500. * # Current cubic to convert
  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, 433, __pyx_L1_error)
  5503. __Pyx_GOTREF(__pyx_t_8);
  5504. __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v_next_q1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __pyx_L1_error)
  5505. __Pyx_GOTREF(__pyx_t_2);
  5506. __pyx_t_10 = PyList_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 433, __pyx_L1_error)
  5507. __Pyx_GOTREF(__pyx_t_10);
  5508. __Pyx_GIVEREF(__pyx_t_8);
  5509. if (__Pyx_PyList_SET_ITEM(__pyx_t_10, 0, __pyx_t_8) != (0)) __PYX_ERR(0, 433, __pyx_L1_error);
  5510. __Pyx_GIVEREF(__pyx_t_2);
  5511. if (__Pyx_PyList_SET_ITEM(__pyx_t_10, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 433, __pyx_L1_error);
  5512. __pyx_t_8 = 0;
  5513. __pyx_t_2 = 0;
  5514. __pyx_v_spline = ((PyObject*)__pyx_t_10);
  5515. __pyx_t_10 = 0;
  5516. /* "fontTools/cu2qu/cu2qu.py":434
  5517. * d1 = 0j
  5518. * spline = [cubic[0], next_q1]
  5519. * for i in range(1, n + 1): # <<<<<<<<<<<<<<
  5520. * # Current cubic to convert
  5521. * c0, c1, c2, c3 = next_cubic
  5522. */
  5523. __pyx_t_11 = (__pyx_v_n + 1);
  5524. __pyx_t_12 = __pyx_t_11;
  5525. for (__pyx_t_13 = 1; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
  5526. __pyx_v_i = __pyx_t_13;
  5527. /* "fontTools/cu2qu/cu2qu.py":436
  5528. * for i in range(1, n + 1):
  5529. * # Current cubic to convert
  5530. * c0, c1, c2, c3 = next_cubic # <<<<<<<<<<<<<<
  5531. *
  5532. * # Current quadratic approximation of current cubic
  5533. */
  5534. if ((likely(PyTuple_CheckExact(__pyx_v_next_cubic))) || (PyList_CheckExact(__pyx_v_next_cubic))) {
  5535. PyObject* sequence = __pyx_v_next_cubic;
  5536. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  5537. if (unlikely(size != 4)) {
  5538. if (size > 4) __Pyx_RaiseTooManyValuesError(4);
  5539. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  5540. __PYX_ERR(0, 436, __pyx_L1_error)
  5541. }
  5542. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5543. if (likely(PyTuple_CheckExact(sequence))) {
  5544. __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0);
  5545. __Pyx_INCREF(__pyx_t_10);
  5546. __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
  5547. __Pyx_INCREF(__pyx_t_2);
  5548. __pyx_t_8 = PyTuple_GET_ITEM(sequence, 2);
  5549. __Pyx_INCREF(__pyx_t_8);
  5550. __pyx_t_14 = PyTuple_GET_ITEM(sequence, 3);
  5551. __Pyx_INCREF(__pyx_t_14);
  5552. } else {
  5553. __pyx_t_10 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  5554. if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 436, __pyx_L1_error)
  5555. __Pyx_XGOTREF(__pyx_t_10);
  5556. __pyx_t_2 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  5557. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 436, __pyx_L1_error)
  5558. __Pyx_XGOTREF(__pyx_t_2);
  5559. __pyx_t_8 = __Pyx_PyList_GetItemRefFast(sequence, 2, __Pyx_ReferenceSharing_SharedReference);
  5560. if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 436, __pyx_L1_error)
  5561. __Pyx_XGOTREF(__pyx_t_8);
  5562. __pyx_t_14 = __Pyx_PyList_GetItemRefFast(sequence, 3, __Pyx_ReferenceSharing_SharedReference);
  5563. if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 436, __pyx_L1_error)
  5564. __Pyx_XGOTREF(__pyx_t_14);
  5565. }
  5566. #else
  5567. {
  5568. Py_ssize_t i;
  5569. PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_2,&__pyx_t_8,&__pyx_t_14};
  5570. for (i=0; i < 4; i++) {
  5571. PyObject* item = __Pyx_PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 436, __pyx_L1_error)
  5572. __Pyx_GOTREF(item);
  5573. *(temps[i]) = item;
  5574. }
  5575. }
  5576. #endif
  5577. } else {
  5578. Py_ssize_t index = -1;
  5579. PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_2,&__pyx_t_8,&__pyx_t_14};
  5580. __pyx_t_15 = PyObject_GetIter(__pyx_v_next_cubic); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 436, __pyx_L1_error)
  5581. __Pyx_GOTREF(__pyx_t_15);
  5582. __pyx_t_16 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_15);
  5583. for (index=0; index < 4; index++) {
  5584. PyObject* item = __pyx_t_16(__pyx_t_15); if (unlikely(!item)) goto __pyx_L9_unpacking_failed;
  5585. __Pyx_GOTREF(item);
  5586. *(temps[index]) = item;
  5587. }
  5588. if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_15), 4) < (0)) __PYX_ERR(0, 436, __pyx_L1_error)
  5589. __pyx_t_16 = NULL;
  5590. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  5591. goto __pyx_L10_unpacking_done;
  5592. __pyx_L9_unpacking_failed:;
  5593. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  5594. __pyx_t_16 = NULL;
  5595. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  5596. __PYX_ERR(0, 436, __pyx_L1_error)
  5597. __pyx_L10_unpacking_done:;
  5598. }
  5599. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_10); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 436, __pyx_L1_error)
  5600. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  5601. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 436, __pyx_L1_error)
  5602. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5603. __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 436, __pyx_L1_error)
  5604. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5605. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 436, __pyx_L1_error)
  5606. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5607. __pyx_v_c0 = __pyx_t_9;
  5608. __pyx_v_c1 = __pyx_t_4;
  5609. __pyx_v_c2 = __pyx_t_5;
  5610. __pyx_v_c3 = __pyx_t_6;
  5611. /* "fontTools/cu2qu/cu2qu.py":439
  5612. *
  5613. * # Current quadratic approximation of current cubic
  5614. * q0 = q2 # <<<<<<<<<<<<<<
  5615. * q1 = next_q1
  5616. * if i < n:
  5617. */
  5618. __pyx_v_q0 = __pyx_v_q2;
  5619. /* "fontTools/cu2qu/cu2qu.py":440
  5620. * # Current quadratic approximation of current cubic
  5621. * q0 = q2
  5622. * q1 = next_q1 # <<<<<<<<<<<<<<
  5623. * if i < n:
  5624. * next_cubic = next(cubics)
  5625. */
  5626. __pyx_v_q1 = __pyx_v_next_q1;
  5627. /* "fontTools/cu2qu/cu2qu.py":441
  5628. * q0 = q2
  5629. * q1 = next_q1
  5630. * if i < n: # <<<<<<<<<<<<<<
  5631. * next_cubic = next(cubics)
  5632. * next_q1 = cubic_approx_control(
  5633. */
  5634. __pyx_t_1 = (__pyx_v_i < __pyx_v_n);
  5635. if (__pyx_t_1) {
  5636. /* "fontTools/cu2qu/cu2qu.py":442
  5637. * q1 = next_q1
  5638. * if i < n:
  5639. * next_cubic = next(cubics) # <<<<<<<<<<<<<<
  5640. * next_q1 = cubic_approx_control(
  5641. * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3]
  5642. */
  5643. __pyx_t_14 = __Pyx_PyIter_Next(__pyx_v_cubics); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 442, __pyx_L1_error)
  5644. __Pyx_GOTREF(__pyx_t_14);
  5645. __Pyx_DECREF_SET(__pyx_v_next_cubic, __pyx_t_14);
  5646. __pyx_t_14 = 0;
  5647. /* "fontTools/cu2qu/cu2qu.py":444
  5648. * next_cubic = next(cubics)
  5649. * next_q1 = cubic_approx_control(
  5650. * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] # <<<<<<<<<<<<<<
  5651. * )
  5652. * spline.append(next_q1)
  5653. */
  5654. __pyx_t_17 = (__pyx_v_n - 1);
  5655. if (unlikely(__pyx_t_17 == 0)) {
  5656. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  5657. __PYX_ERR(0, 444, __pyx_L1_error)
  5658. }
  5659. __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)
  5660. __Pyx_GOTREF(__pyx_t_14);
  5661. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 444, __pyx_L1_error)
  5662. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5663. __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)
  5664. __Pyx_GOTREF(__pyx_t_14);
  5665. __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 444, __pyx_L1_error)
  5666. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5667. __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)
  5668. __Pyx_GOTREF(__pyx_t_14);
  5669. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 444, __pyx_L1_error)
  5670. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5671. __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)
  5672. __Pyx_GOTREF(__pyx_t_14);
  5673. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 444, __pyx_L1_error)
  5674. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5675. /* "fontTools/cu2qu/cu2qu.py":443
  5676. * if i < n:
  5677. * next_cubic = next(cubics)
  5678. * next_q1 = cubic_approx_control( # <<<<<<<<<<<<<<
  5679. * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3]
  5680. * )
  5681. */
  5682. __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)
  5683. __pyx_v_next_q1 = __pyx_t_7;
  5684. /* "fontTools/cu2qu/cu2qu.py":446
  5685. * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3]
  5686. * )
  5687. * spline.append(next_q1) # <<<<<<<<<<<<<<
  5688. * q2 = (q1 + next_q1) * 0.5
  5689. * else:
  5690. */
  5691. __pyx_t_14 = __pyx_PyComplex_FromComplex(__pyx_v_next_q1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 446, __pyx_L1_error)
  5692. __Pyx_GOTREF(__pyx_t_14);
  5693. __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)
  5694. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5695. /* "fontTools/cu2qu/cu2qu.py":447
  5696. * )
  5697. * spline.append(next_q1)
  5698. * q2 = (q1 + next_q1) * 0.5 # <<<<<<<<<<<<<<
  5699. * else:
  5700. * q2 = c3
  5701. */
  5702. __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));
  5703. /* "fontTools/cu2qu/cu2qu.py":441
  5704. * q0 = q2
  5705. * q1 = next_q1
  5706. * if i < n: # <<<<<<<<<<<<<<
  5707. * next_cubic = next(cubics)
  5708. * next_q1 = cubic_approx_control(
  5709. */
  5710. goto __pyx_L11;
  5711. }
  5712. /* "fontTools/cu2qu/cu2qu.py":449
  5713. * q2 = (q1 + next_q1) * 0.5
  5714. * else:
  5715. * q2 = c3 # <<<<<<<<<<<<<<
  5716. *
  5717. * # End-point deltas
  5718. */
  5719. /*else*/ {
  5720. __pyx_v_q2 = __pyx_v_c3;
  5721. }
  5722. __pyx_L11:;
  5723. /* "fontTools/cu2qu/cu2qu.py":452
  5724. *
  5725. * # End-point deltas
  5726. * d0 = d1 # <<<<<<<<<<<<<<
  5727. * d1 = q2 - c3
  5728. *
  5729. */
  5730. __pyx_v_d0 = __pyx_v_d1;
  5731. /* "fontTools/cu2qu/cu2qu.py":453
  5732. * # End-point deltas
  5733. * d0 = d1
  5734. * d1 = q2 - c3 # <<<<<<<<<<<<<<
  5735. *
  5736. * if abs(d1) > tolerance or not cubic_farthest_fit_inside(
  5737. */
  5738. __pyx_v_d1 = __Pyx_c_diff_double(__pyx_v_q2, __pyx_v_c3);
  5739. /* "fontTools/cu2qu/cu2qu.py":455
  5740. * d1 = q2 - c3
  5741. *
  5742. * if abs(d1) > tolerance or not cubic_farthest_fit_inside( # <<<<<<<<<<<<<<
  5743. * d0,
  5744. * q0 + (q1 - q0) * (2 / 3) - c1,
  5745. */
  5746. __pyx_t_3 = (__Pyx_c_abs_double(__pyx_v_d1) > __pyx_v_tolerance);
  5747. if (!__pyx_t_3) {
  5748. } else {
  5749. __pyx_t_1 = __pyx_t_3;
  5750. goto __pyx_L13_bool_binop_done;
  5751. }
  5752. /* "fontTools/cu2qu/cu2qu.py":460
  5753. * q2 + (q1 - q2) * (2 / 3) - c2,
  5754. * d1,
  5755. * tolerance, # <<<<<<<<<<<<<<
  5756. * ):
  5757. * return None
  5758. */
  5759. __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)
  5760. /* "fontTools/cu2qu/cu2qu.py":455
  5761. * d1 = q2 - c3
  5762. *
  5763. * if abs(d1) > tolerance or not cubic_farthest_fit_inside( # <<<<<<<<<<<<<<
  5764. * d0,
  5765. * q0 + (q1 - q0) * (2 / 3) - c1,
  5766. */
  5767. __pyx_t_3 = (!(__pyx_t_19 != 0));
  5768. __pyx_t_1 = __pyx_t_3;
  5769. __pyx_L13_bool_binop_done:;
  5770. if (__pyx_t_1) {
  5771. /* "fontTools/cu2qu/cu2qu.py":462
  5772. * tolerance,
  5773. * ):
  5774. * return None # <<<<<<<<<<<<<<
  5775. * spline.append(cubic[3])
  5776. *
  5777. */
  5778. __Pyx_XDECREF(__pyx_r);
  5779. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5780. goto __pyx_L0;
  5781. /* "fontTools/cu2qu/cu2qu.py":455
  5782. * d1 = q2 - c3
  5783. *
  5784. * if abs(d1) > tolerance or not cubic_farthest_fit_inside( # <<<<<<<<<<<<<<
  5785. * d0,
  5786. * q0 + (q1 - q0) * (2 / 3) - c1,
  5787. */
  5788. }
  5789. }
  5790. /* "fontTools/cu2qu/cu2qu.py":463
  5791. * ):
  5792. * return None
  5793. * spline.append(cubic[3]) # <<<<<<<<<<<<<<
  5794. *
  5795. * return spline
  5796. */
  5797. __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)
  5798. __Pyx_GOTREF(__pyx_t_14);
  5799. __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)
  5800. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5801. /* "fontTools/cu2qu/cu2qu.py":465
  5802. * spline.append(cubic[3])
  5803. *
  5804. * return spline # <<<<<<<<<<<<<<
  5805. *
  5806. *
  5807. */
  5808. __Pyx_XDECREF(__pyx_r);
  5809. __Pyx_INCREF(__pyx_v_spline);
  5810. __pyx_r = __pyx_v_spline;
  5811. goto __pyx_L0;
  5812. /* "fontTools/cu2qu/cu2qu.py":390
  5813. *
  5814. *
  5815. * @cython.cfunc # <<<<<<<<<<<<<<
  5816. * @cython.locals(n=cython.int, tolerance=cython.double)
  5817. * @cython.locals(i=cython.int)
  5818. */
  5819. /* function exit code */
  5820. __pyx_L1_error:;
  5821. __Pyx_XDECREF(__pyx_t_2);
  5822. __Pyx_XDECREF(__pyx_t_8);
  5823. __Pyx_XDECREF(__pyx_t_10);
  5824. __Pyx_XDECREF(__pyx_t_14);
  5825. __Pyx_XDECREF(__pyx_t_15);
  5826. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.cubic_approx_spline", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5827. __pyx_r = 0;
  5828. __pyx_L0:;
  5829. __Pyx_XDECREF(__pyx_v_cubics);
  5830. __Pyx_XDECREF(__pyx_v_next_cubic);
  5831. __Pyx_XDECREF(__pyx_v_spline);
  5832. __Pyx_XGIVEREF(__pyx_r);
  5833. __Pyx_RefNannyFinishContext();
  5834. return __pyx_r;
  5835. }
  5836. /* "fontTools/cu2qu/cu2qu.py":468
  5837. *
  5838. *
  5839. * @cython.locals(max_err=cython.double) # <<<<<<<<<<<<<<
  5840. * @cython.locals(n=cython.int)
  5841. * @cython.locals(all_quadratic=cython.int)
  5842. */
  5843. /* Python wrapper */
  5844. static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic(PyObject *__pyx_self,
  5845. #if CYTHON_METH_FASTCALL
  5846. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  5847. #else
  5848. PyObject *__pyx_args, PyObject *__pyx_kwds
  5849. #endif
  5850. ); /*proto*/
  5851. 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.\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).\n\nRaises:\n fontTools.cu2qu.errors.ApproxNotFoundError: if no suitable\n approximation can be found with the given parameters.");
  5852. 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};
  5853. static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic(PyObject *__pyx_self,
  5854. #if CYTHON_METH_FASTCALL
  5855. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  5856. #else
  5857. PyObject *__pyx_args, PyObject *__pyx_kwds
  5858. #endif
  5859. ) {
  5860. PyObject *__pyx_v_curve = 0;
  5861. double __pyx_v_max_err;
  5862. int __pyx_v_all_quadratic;
  5863. #if !CYTHON_METH_FASTCALL
  5864. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  5865. #endif
  5866. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  5867. PyObject* values[3] = {0,0,0};
  5868. int __pyx_lineno = 0;
  5869. const char *__pyx_filename = NULL;
  5870. int __pyx_clineno = 0;
  5871. PyObject *__pyx_r = 0;
  5872. __Pyx_RefNannyDeclarations
  5873. __Pyx_RefNannySetupContext("curve_to_quadratic (wrapper)", 0);
  5874. #if !CYTHON_METH_FASTCALL
  5875. #if CYTHON_ASSUME_SAFE_SIZE
  5876. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  5877. #else
  5878. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  5879. #endif
  5880. #endif
  5881. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  5882. {
  5883. 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};
  5884. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  5885. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 468, __pyx_L3_error)
  5886. if (__pyx_kwds_len > 0) {
  5887. switch (__pyx_nargs) {
  5888. case 3:
  5889. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  5890. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 468, __pyx_L3_error)
  5891. CYTHON_FALLTHROUGH;
  5892. case 2:
  5893. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  5894. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 468, __pyx_L3_error)
  5895. CYTHON_FALLTHROUGH;
  5896. case 1:
  5897. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  5898. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 468, __pyx_L3_error)
  5899. CYTHON_FALLTHROUGH;
  5900. case 0: break;
  5901. default: goto __pyx_L5_argtuple_error;
  5902. }
  5903. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  5904. 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)
  5905. for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
  5906. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("curve_to_quadratic", 0, 2, 3, i); __PYX_ERR(0, 468, __pyx_L3_error) }
  5907. }
  5908. } else {
  5909. switch (__pyx_nargs) {
  5910. case 3:
  5911. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  5912. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 468, __pyx_L3_error)
  5913. CYTHON_FALLTHROUGH;
  5914. case 2:
  5915. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  5916. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 468, __pyx_L3_error)
  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. break;
  5920. default: goto __pyx_L5_argtuple_error;
  5921. }
  5922. }
  5923. __pyx_v_curve = values[0];
  5924. __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)
  5925. if (values[2]) {
  5926. __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)
  5927. } else {
  5928. /* "fontTools/cu2qu/cu2qu.py":471
  5929. * @cython.locals(n=cython.int)
  5930. * @cython.locals(all_quadratic=cython.int)
  5931. * def curve_to_quadratic(curve, max_err, all_quadratic=True): # <<<<<<<<<<<<<<
  5932. * """Approximate a cubic Bezier curve with a spline of n quadratics.
  5933. *
  5934. */
  5935. __pyx_v_all_quadratic = ((int)((int)1));
  5936. }
  5937. }
  5938. goto __pyx_L6_skip;
  5939. __pyx_L5_argtuple_error:;
  5940. __Pyx_RaiseArgtupleInvalid("curve_to_quadratic", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 468, __pyx_L3_error)
  5941. __pyx_L6_skip:;
  5942. goto __pyx_L4_argument_unpacking_done;
  5943. __pyx_L3_error:;
  5944. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  5945. Py_XDECREF(values[__pyx_temp]);
  5946. }
  5947. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curve_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5948. __Pyx_RefNannyFinishContext();
  5949. return NULL;
  5950. __pyx_L4_argument_unpacking_done:;
  5951. __pyx_r = __pyx_pf_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic(__pyx_self, __pyx_v_curve, __pyx_v_max_err, __pyx_v_all_quadratic);
  5952. /* "fontTools/cu2qu/cu2qu.py":468
  5953. *
  5954. *
  5955. * @cython.locals(max_err=cython.double) # <<<<<<<<<<<<<<
  5956. * @cython.locals(n=cython.int)
  5957. * @cython.locals(all_quadratic=cython.int)
  5958. */
  5959. /* function exit code */
  5960. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  5961. Py_XDECREF(values[__pyx_temp]);
  5962. }
  5963. __Pyx_RefNannyFinishContext();
  5964. return __pyx_r;
  5965. }
  5966. 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) {
  5967. int __pyx_v_n;
  5968. PyObject *__pyx_v_spline = NULL;
  5969. PyObject *__pyx_7genexpr__pyx_v_p = NULL;
  5970. PyObject *__pyx_8genexpr1__pyx_v_s = NULL;
  5971. PyObject *__pyx_r = NULL;
  5972. __Pyx_RefNannyDeclarations
  5973. PyObject *__pyx_t_1 = NULL;
  5974. PyObject *__pyx_t_2 = NULL;
  5975. Py_ssize_t __pyx_t_3;
  5976. PyObject *(*__pyx_t_4)(PyObject *);
  5977. PyObject *__pyx_t_5 = NULL;
  5978. PyObject *__pyx_t_6 = NULL;
  5979. Py_ssize_t __pyx_t_7;
  5980. int __pyx_t_8;
  5981. int __pyx_t_9;
  5982. Py_ssize_t __pyx_t_10;
  5983. PyObject *__pyx_t_11 = NULL;
  5984. size_t __pyx_t_12;
  5985. int __pyx_lineno = 0;
  5986. const char *__pyx_filename = NULL;
  5987. int __pyx_clineno = 0;
  5988. __Pyx_RefNannySetupContext("curve_to_quadratic", 0);
  5989. __Pyx_INCREF(__pyx_v_curve);
  5990. /* "fontTools/cu2qu/cu2qu.py":494
  5991. * """
  5992. *
  5993. * curve = [complex(*p) for p in curve] # <<<<<<<<<<<<<<
  5994. *
  5995. * for n in range(1, MAX_N + 1):
  5996. */
  5997. { /* enter inner scope */
  5998. __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 494, __pyx_L5_error)
  5999. __Pyx_GOTREF(__pyx_t_1);
  6000. if (likely(PyList_CheckExact(__pyx_v_curve)) || PyTuple_CheckExact(__pyx_v_curve)) {
  6001. __pyx_t_2 = __pyx_v_curve; __Pyx_INCREF(__pyx_t_2);
  6002. __pyx_t_3 = 0;
  6003. __pyx_t_4 = NULL;
  6004. } else {
  6005. __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_curve); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 494, __pyx_L5_error)
  6006. __Pyx_GOTREF(__pyx_t_2);
  6007. __pyx_t_4 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 494, __pyx_L5_error)
  6008. }
  6009. for (;;) {
  6010. if (likely(!__pyx_t_4)) {
  6011. if (likely(PyList_CheckExact(__pyx_t_2))) {
  6012. {
  6013. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
  6014. #if !CYTHON_ASSUME_SAFE_SIZE
  6015. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 494, __pyx_L5_error)
  6016. #endif
  6017. if (__pyx_t_3 >= __pyx_temp) break;
  6018. }
  6019. __pyx_t_5 = __Pyx_PyList_GetItemRefFast(__pyx_t_2, __pyx_t_3, __Pyx_ReferenceSharing_OwnStrongReference);
  6020. ++__pyx_t_3;
  6021. } else {
  6022. {
  6023. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2);
  6024. #if !CYTHON_ASSUME_SAFE_SIZE
  6025. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 494, __pyx_L5_error)
  6026. #endif
  6027. if (__pyx_t_3 >= __pyx_temp) break;
  6028. }
  6029. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6030. __pyx_t_5 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3));
  6031. #else
  6032. __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3);
  6033. #endif
  6034. ++__pyx_t_3;
  6035. }
  6036. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 494, __pyx_L5_error)
  6037. } else {
  6038. __pyx_t_5 = __pyx_t_4(__pyx_t_2);
  6039. if (unlikely(!__pyx_t_5)) {
  6040. PyObject* exc_type = PyErr_Occurred();
  6041. if (exc_type) {
  6042. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 494, __pyx_L5_error)
  6043. PyErr_Clear();
  6044. }
  6045. break;
  6046. }
  6047. }
  6048. __Pyx_GOTREF(__pyx_t_5);
  6049. __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_p, __pyx_t_5);
  6050. __pyx_t_5 = 0;
  6051. __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_7genexpr__pyx_v_p); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 494, __pyx_L5_error)
  6052. __Pyx_GOTREF(__pyx_t_5);
  6053. __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&PyComplex_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 494, __pyx_L5_error)
  6054. __Pyx_GOTREF(__pyx_t_6);
  6055. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6056. if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 494, __pyx_L5_error)
  6057. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6058. }
  6059. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6060. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_p); __pyx_7genexpr__pyx_v_p = 0;
  6061. goto __pyx_L9_exit_scope;
  6062. __pyx_L5_error:;
  6063. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_p); __pyx_7genexpr__pyx_v_p = 0;
  6064. goto __pyx_L1_error;
  6065. __pyx_L9_exit_scope:;
  6066. } /* exit inner scope */
  6067. __Pyx_DECREF_SET(__pyx_v_curve, __pyx_t_1);
  6068. __pyx_t_1 = 0;
  6069. /* "fontTools/cu2qu/cu2qu.py":496
  6070. * curve = [complex(*p) for p in curve]
  6071. *
  6072. * for n in range(1, MAX_N + 1): # <<<<<<<<<<<<<<
  6073. * spline = cubic_approx_spline(curve, n, max_err, all_quadratic)
  6074. * if spline is not None:
  6075. */
  6076. __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_MAX_N); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error)
  6077. __Pyx_GOTREF(__pyx_t_1);
  6078. __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, 496, __pyx_L1_error)
  6079. __Pyx_GOTREF(__pyx_t_2);
  6080. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6081. __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 496, __pyx_L1_error)
  6082. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6083. __pyx_t_7 = __pyx_t_3;
  6084. for (__pyx_t_8 = 1; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
  6085. __pyx_v_n = __pyx_t_8;
  6086. /* "fontTools/cu2qu/cu2qu.py":497
  6087. *
  6088. * for n in range(1, MAX_N + 1):
  6089. * spline = cubic_approx_spline(curve, n, max_err, all_quadratic) # <<<<<<<<<<<<<<
  6090. * if spline is not None:
  6091. * # done. go home
  6092. */
  6093. __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, 497, __pyx_L1_error)
  6094. __Pyx_GOTREF(__pyx_t_2);
  6095. __Pyx_XDECREF_SET(__pyx_v_spline, __pyx_t_2);
  6096. __pyx_t_2 = 0;
  6097. /* "fontTools/cu2qu/cu2qu.py":498
  6098. * for n in range(1, MAX_N + 1):
  6099. * spline = cubic_approx_spline(curve, n, max_err, all_quadratic)
  6100. * if spline is not None: # <<<<<<<<<<<<<<
  6101. * # done. go home
  6102. * return [(s.real, s.imag) for s in spline]
  6103. */
  6104. __pyx_t_9 = (__pyx_v_spline != Py_None);
  6105. if (__pyx_t_9) {
  6106. /* "fontTools/cu2qu/cu2qu.py":500
  6107. * if spline is not None:
  6108. * # done. go home
  6109. * return [(s.real, s.imag) for s in spline] # <<<<<<<<<<<<<<
  6110. *
  6111. * raise ApproxNotFoundError(curve)
  6112. */
  6113. __Pyx_XDECREF(__pyx_r);
  6114. { /* enter inner scope */
  6115. __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 500, __pyx_L15_error)
  6116. __Pyx_GOTREF(__pyx_t_2);
  6117. if (likely(PyList_CheckExact(__pyx_v_spline)) || PyTuple_CheckExact(__pyx_v_spline)) {
  6118. __pyx_t_1 = __pyx_v_spline; __Pyx_INCREF(__pyx_t_1);
  6119. __pyx_t_10 = 0;
  6120. __pyx_t_4 = NULL;
  6121. } else {
  6122. __pyx_t_10 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_spline); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 500, __pyx_L15_error)
  6123. __Pyx_GOTREF(__pyx_t_1);
  6124. __pyx_t_4 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 500, __pyx_L15_error)
  6125. }
  6126. for (;;) {
  6127. if (likely(!__pyx_t_4)) {
  6128. if (likely(PyList_CheckExact(__pyx_t_1))) {
  6129. {
  6130. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
  6131. #if !CYTHON_ASSUME_SAFE_SIZE
  6132. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 500, __pyx_L15_error)
  6133. #endif
  6134. if (__pyx_t_10 >= __pyx_temp) break;
  6135. }
  6136. __pyx_t_6 = __Pyx_PyList_GetItemRefFast(__pyx_t_1, __pyx_t_10, __Pyx_ReferenceSharing_OwnStrongReference);
  6137. ++__pyx_t_10;
  6138. } else {
  6139. {
  6140. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
  6141. #if !CYTHON_ASSUME_SAFE_SIZE
  6142. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 500, __pyx_L15_error)
  6143. #endif
  6144. if (__pyx_t_10 >= __pyx_temp) break;
  6145. }
  6146. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6147. __pyx_t_6 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_10));
  6148. #else
  6149. __pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_10);
  6150. #endif
  6151. ++__pyx_t_10;
  6152. }
  6153. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 500, __pyx_L15_error)
  6154. } else {
  6155. __pyx_t_6 = __pyx_t_4(__pyx_t_1);
  6156. if (unlikely(!__pyx_t_6)) {
  6157. PyObject* exc_type = PyErr_Occurred();
  6158. if (exc_type) {
  6159. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 500, __pyx_L15_error)
  6160. PyErr_Clear();
  6161. }
  6162. break;
  6163. }
  6164. }
  6165. __Pyx_GOTREF(__pyx_t_6);
  6166. __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_s, __pyx_t_6);
  6167. __pyx_t_6 = 0;
  6168. __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, 500, __pyx_L15_error)
  6169. __Pyx_GOTREF(__pyx_t_6);
  6170. __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, 500, __pyx_L15_error)
  6171. __Pyx_GOTREF(__pyx_t_5);
  6172. __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 500, __pyx_L15_error)
  6173. __Pyx_GOTREF(__pyx_t_11);
  6174. __Pyx_GIVEREF(__pyx_t_6);
  6175. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6) != (0)) __PYX_ERR(0, 500, __pyx_L15_error);
  6176. __Pyx_GIVEREF(__pyx_t_5);
  6177. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 500, __pyx_L15_error);
  6178. __pyx_t_6 = 0;
  6179. __pyx_t_5 = 0;
  6180. if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 500, __pyx_L15_error)
  6181. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  6182. }
  6183. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6184. __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_s); __pyx_8genexpr1__pyx_v_s = 0;
  6185. goto __pyx_L19_exit_scope;
  6186. __pyx_L15_error:;
  6187. __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_s); __pyx_8genexpr1__pyx_v_s = 0;
  6188. goto __pyx_L1_error;
  6189. __pyx_L19_exit_scope:;
  6190. } /* exit inner scope */
  6191. __pyx_r = __pyx_t_2;
  6192. __pyx_t_2 = 0;
  6193. goto __pyx_L0;
  6194. /* "fontTools/cu2qu/cu2qu.py":498
  6195. * for n in range(1, MAX_N + 1):
  6196. * spline = cubic_approx_spline(curve, n, max_err, all_quadratic)
  6197. * if spline is not None: # <<<<<<<<<<<<<<
  6198. * # done. go home
  6199. * return [(s.real, s.imag) for s in spline]
  6200. */
  6201. }
  6202. }
  6203. /* "fontTools/cu2qu/cu2qu.py":502
  6204. * return [(s.real, s.imag) for s in spline]
  6205. *
  6206. * raise ApproxNotFoundError(curve) # <<<<<<<<<<<<<<
  6207. *
  6208. *
  6209. */
  6210. __pyx_t_1 = NULL;
  6211. __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_ApproxNotFoundError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 502, __pyx_L1_error)
  6212. __Pyx_GOTREF(__pyx_t_11);
  6213. __pyx_t_12 = 1;
  6214. #if CYTHON_UNPACK_METHODS
  6215. if (unlikely(PyMethod_Check(__pyx_t_11))) {
  6216. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11);
  6217. assert(__pyx_t_1);
  6218. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_11);
  6219. __Pyx_INCREF(__pyx_t_1);
  6220. __Pyx_INCREF(__pyx__function);
  6221. __Pyx_DECREF_SET(__pyx_t_11, __pyx__function);
  6222. __pyx_t_12 = 0;
  6223. }
  6224. #endif
  6225. {
  6226. PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_curve};
  6227. __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));
  6228. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  6229. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  6230. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 502, __pyx_L1_error)
  6231. __Pyx_GOTREF(__pyx_t_2);
  6232. }
  6233. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  6234. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6235. __PYX_ERR(0, 502, __pyx_L1_error)
  6236. /* "fontTools/cu2qu/cu2qu.py":468
  6237. *
  6238. *
  6239. * @cython.locals(max_err=cython.double) # <<<<<<<<<<<<<<
  6240. * @cython.locals(n=cython.int)
  6241. * @cython.locals(all_quadratic=cython.int)
  6242. */
  6243. /* function exit code */
  6244. __pyx_L1_error:;
  6245. __Pyx_XDECREF(__pyx_t_1);
  6246. __Pyx_XDECREF(__pyx_t_2);
  6247. __Pyx_XDECREF(__pyx_t_5);
  6248. __Pyx_XDECREF(__pyx_t_6);
  6249. __Pyx_XDECREF(__pyx_t_11);
  6250. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curve_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6251. __pyx_r = NULL;
  6252. __pyx_L0:;
  6253. __Pyx_XDECREF(__pyx_v_spline);
  6254. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_p);
  6255. __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_s);
  6256. __Pyx_XDECREF(__pyx_v_curve);
  6257. __Pyx_XGIVEREF(__pyx_r);
  6258. __Pyx_RefNannyFinishContext();
  6259. return __pyx_r;
  6260. }
  6261. /* "fontTools/cu2qu/cu2qu.py":505
  6262. *
  6263. *
  6264. * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) # <<<<<<<<<<<<<<
  6265. * @cython.locals(all_quadratic=cython.int)
  6266. * def curves_to_quadratic(curves, max_errors, all_quadratic=True):
  6267. */
  6268. /* Python wrapper */
  6269. static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic(PyObject *__pyx_self,
  6270. #if CYTHON_METH_FASTCALL
  6271. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  6272. #else
  6273. PyObject *__pyx_args, PyObject *__pyx_kwds
  6274. #endif
  6275. ); /*proto*/
  6276. 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. If ``curves`` is empty, returns an empty list.\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 ValueError: if ``max_errors`` does not match the number of curves.\n fontTools.cu2qu.errors.ApproxNotFoundError: if no suitable approximation\n can be found for all curves with the given parameters.");
  6277. 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};
  6278. static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic(PyObject *__pyx_self,
  6279. #if CYTHON_METH_FASTCALL
  6280. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  6281. #else
  6282. PyObject *__pyx_args, PyObject *__pyx_kwds
  6283. #endif
  6284. ) {
  6285. PyObject *__pyx_v_curves = 0;
  6286. PyObject *__pyx_v_max_errors = 0;
  6287. int __pyx_v_all_quadratic;
  6288. #if !CYTHON_METH_FASTCALL
  6289. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  6290. #endif
  6291. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  6292. PyObject* values[3] = {0,0,0};
  6293. int __pyx_lineno = 0;
  6294. const char *__pyx_filename = NULL;
  6295. int __pyx_clineno = 0;
  6296. PyObject *__pyx_r = 0;
  6297. __Pyx_RefNannyDeclarations
  6298. __Pyx_RefNannySetupContext("curves_to_quadratic (wrapper)", 0);
  6299. #if !CYTHON_METH_FASTCALL
  6300. #if CYTHON_ASSUME_SAFE_SIZE
  6301. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  6302. #else
  6303. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  6304. #endif
  6305. #endif
  6306. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  6307. {
  6308. 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};
  6309. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  6310. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 505, __pyx_L3_error)
  6311. if (__pyx_kwds_len > 0) {
  6312. switch (__pyx_nargs) {
  6313. case 3:
  6314. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  6315. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 505, __pyx_L3_error)
  6316. CYTHON_FALLTHROUGH;
  6317. case 2:
  6318. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  6319. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 505, __pyx_L3_error)
  6320. CYTHON_FALLTHROUGH;
  6321. case 1:
  6322. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  6323. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 505, __pyx_L3_error)
  6324. CYTHON_FALLTHROUGH;
  6325. case 0: break;
  6326. default: goto __pyx_L5_argtuple_error;
  6327. }
  6328. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  6329. 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, 505, __pyx_L3_error)
  6330. for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
  6331. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("curves_to_quadratic", 0, 2, 3, i); __PYX_ERR(0, 505, __pyx_L3_error) }
  6332. }
  6333. } else {
  6334. switch (__pyx_nargs) {
  6335. case 3:
  6336. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  6337. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 505, __pyx_L3_error)
  6338. CYTHON_FALLTHROUGH;
  6339. case 2:
  6340. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  6341. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 505, __pyx_L3_error)
  6342. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  6343. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 505, __pyx_L3_error)
  6344. break;
  6345. default: goto __pyx_L5_argtuple_error;
  6346. }
  6347. }
  6348. __pyx_v_curves = values[0];
  6349. __pyx_v_max_errors = values[1];
  6350. if (values[2]) {
  6351. __pyx_v_all_quadratic = __Pyx_PyLong_As_int(values[2]); if (unlikely((__pyx_v_all_quadratic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 507, __pyx_L3_error)
  6352. } else {
  6353. /* "fontTools/cu2qu/cu2qu.py":507
  6354. * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int)
  6355. * @cython.locals(all_quadratic=cython.int)
  6356. * def curves_to_quadratic(curves, max_errors, all_quadratic=True): # <<<<<<<<<<<<<<
  6357. * """Return quadratic Bezier splines approximating the input cubic Beziers.
  6358. *
  6359. */
  6360. __pyx_v_all_quadratic = ((int)((int)1));
  6361. }
  6362. }
  6363. goto __pyx_L6_skip;
  6364. __pyx_L5_argtuple_error:;
  6365. __Pyx_RaiseArgtupleInvalid("curves_to_quadratic", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 505, __pyx_L3_error)
  6366. __pyx_L6_skip:;
  6367. goto __pyx_L4_argument_unpacking_done;
  6368. __pyx_L3_error:;
  6369. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  6370. Py_XDECREF(values[__pyx_temp]);
  6371. }
  6372. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curves_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6373. __Pyx_RefNannyFinishContext();
  6374. return NULL;
  6375. __pyx_L4_argument_unpacking_done:;
  6376. __pyx_r = __pyx_pf_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic(__pyx_self, __pyx_v_curves, __pyx_v_max_errors, __pyx_v_all_quadratic);
  6377. /* "fontTools/cu2qu/cu2qu.py":505
  6378. *
  6379. *
  6380. * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) # <<<<<<<<<<<<<<
  6381. * @cython.locals(all_quadratic=cython.int)
  6382. * def curves_to_quadratic(curves, max_errors, all_quadratic=True):
  6383. */
  6384. /* function exit code */
  6385. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  6386. Py_XDECREF(values[__pyx_temp]);
  6387. }
  6388. __Pyx_RefNannyFinishContext();
  6389. return __pyx_r;
  6390. }
  6391. 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) {
  6392. int __pyx_v_l;
  6393. int __pyx_v_last_i;
  6394. int __pyx_v_i;
  6395. PyObject *__pyx_v_splines = NULL;
  6396. PyObject *__pyx_v_n = NULL;
  6397. PyObject *__pyx_v_spline = NULL;
  6398. PyObject *__pyx_8genexpr2__pyx_v_curve = NULL;
  6399. PyObject *__pyx_8genexpr3__pyx_v_p = NULL;
  6400. PyObject *__pyx_8genexpr4__pyx_v_spline = NULL;
  6401. PyObject *__pyx_8genexpr5__pyx_v_s = NULL;
  6402. PyObject *__pyx_r = NULL;
  6403. __Pyx_RefNannyDeclarations
  6404. PyObject *__pyx_t_1 = NULL;
  6405. PyObject *__pyx_t_2 = NULL;
  6406. Py_ssize_t __pyx_t_3;
  6407. PyObject *(*__pyx_t_4)(PyObject *);
  6408. PyObject *__pyx_t_5 = NULL;
  6409. PyObject *__pyx_t_6 = NULL;
  6410. Py_ssize_t __pyx_t_7;
  6411. PyObject *(*__pyx_t_8)(PyObject *);
  6412. PyObject *__pyx_t_9 = NULL;
  6413. PyObject *__pyx_t_10 = NULL;
  6414. int __pyx_t_11;
  6415. size_t __pyx_t_12;
  6416. int __pyx_t_13;
  6417. int __pyx_t_14;
  6418. double __pyx_t_15;
  6419. long __pyx_t_16;
  6420. PyObject *__pyx_t_17 = NULL;
  6421. int __pyx_lineno = 0;
  6422. const char *__pyx_filename = NULL;
  6423. int __pyx_clineno = 0;
  6424. __Pyx_RefNannySetupContext("curves_to_quadratic", 0);
  6425. __Pyx_INCREF(__pyx_v_curves);
  6426. /* "fontTools/cu2qu/cu2qu.py":545
  6427. * """
  6428. *
  6429. * curves = [[complex(*p) for p in curve] for curve in curves] # <<<<<<<<<<<<<<
  6430. * if len(max_errors) != len(curves):
  6431. * raise ValueError("max_errors must match the number of curves")
  6432. */
  6433. { /* enter inner scope */
  6434. __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 545, __pyx_L5_error)
  6435. __Pyx_GOTREF(__pyx_t_1);
  6436. if (likely(PyList_CheckExact(__pyx_v_curves)) || PyTuple_CheckExact(__pyx_v_curves)) {
  6437. __pyx_t_2 = __pyx_v_curves; __Pyx_INCREF(__pyx_t_2);
  6438. __pyx_t_3 = 0;
  6439. __pyx_t_4 = NULL;
  6440. } else {
  6441. __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_curves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 545, __pyx_L5_error)
  6442. __Pyx_GOTREF(__pyx_t_2);
  6443. __pyx_t_4 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 545, __pyx_L5_error)
  6444. }
  6445. for (;;) {
  6446. if (likely(!__pyx_t_4)) {
  6447. if (likely(PyList_CheckExact(__pyx_t_2))) {
  6448. {
  6449. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
  6450. #if !CYTHON_ASSUME_SAFE_SIZE
  6451. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 545, __pyx_L5_error)
  6452. #endif
  6453. if (__pyx_t_3 >= __pyx_temp) break;
  6454. }
  6455. __pyx_t_5 = __Pyx_PyList_GetItemRefFast(__pyx_t_2, __pyx_t_3, __Pyx_ReferenceSharing_OwnStrongReference);
  6456. ++__pyx_t_3;
  6457. } else {
  6458. {
  6459. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2);
  6460. #if !CYTHON_ASSUME_SAFE_SIZE
  6461. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 545, __pyx_L5_error)
  6462. #endif
  6463. if (__pyx_t_3 >= __pyx_temp) break;
  6464. }
  6465. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6466. __pyx_t_5 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3));
  6467. #else
  6468. __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3);
  6469. #endif
  6470. ++__pyx_t_3;
  6471. }
  6472. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 545, __pyx_L5_error)
  6473. } else {
  6474. __pyx_t_5 = __pyx_t_4(__pyx_t_2);
  6475. if (unlikely(!__pyx_t_5)) {
  6476. PyObject* exc_type = PyErr_Occurred();
  6477. if (exc_type) {
  6478. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 545, __pyx_L5_error)
  6479. PyErr_Clear();
  6480. }
  6481. break;
  6482. }
  6483. }
  6484. __Pyx_GOTREF(__pyx_t_5);
  6485. __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_curve, __pyx_t_5);
  6486. __pyx_t_5 = 0;
  6487. { /* enter inner scope */
  6488. __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 545, __pyx_L10_error)
  6489. __Pyx_GOTREF(__pyx_t_5);
  6490. if (likely(PyList_CheckExact(__pyx_8genexpr2__pyx_v_curve)) || PyTuple_CheckExact(__pyx_8genexpr2__pyx_v_curve)) {
  6491. __pyx_t_6 = __pyx_8genexpr2__pyx_v_curve; __Pyx_INCREF(__pyx_t_6);
  6492. __pyx_t_7 = 0;
  6493. __pyx_t_8 = NULL;
  6494. } else {
  6495. __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_8genexpr2__pyx_v_curve); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 545, __pyx_L10_error)
  6496. __Pyx_GOTREF(__pyx_t_6);
  6497. __pyx_t_8 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 545, __pyx_L10_error)
  6498. }
  6499. for (;;) {
  6500. if (likely(!__pyx_t_8)) {
  6501. if (likely(PyList_CheckExact(__pyx_t_6))) {
  6502. {
  6503. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  6504. #if !CYTHON_ASSUME_SAFE_SIZE
  6505. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 545, __pyx_L10_error)
  6506. #endif
  6507. if (__pyx_t_7 >= __pyx_temp) break;
  6508. }
  6509. __pyx_t_9 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_7, __Pyx_ReferenceSharing_OwnStrongReference);
  6510. ++__pyx_t_7;
  6511. } else {
  6512. {
  6513. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
  6514. #if !CYTHON_ASSUME_SAFE_SIZE
  6515. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 545, __pyx_L10_error)
  6516. #endif
  6517. if (__pyx_t_7 >= __pyx_temp) break;
  6518. }
  6519. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6520. __pyx_t_9 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7));
  6521. #else
  6522. __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_7);
  6523. #endif
  6524. ++__pyx_t_7;
  6525. }
  6526. if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 545, __pyx_L10_error)
  6527. } else {
  6528. __pyx_t_9 = __pyx_t_8(__pyx_t_6);
  6529. if (unlikely(!__pyx_t_9)) {
  6530. PyObject* exc_type = PyErr_Occurred();
  6531. if (exc_type) {
  6532. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 545, __pyx_L10_error)
  6533. PyErr_Clear();
  6534. }
  6535. break;
  6536. }
  6537. }
  6538. __Pyx_GOTREF(__pyx_t_9);
  6539. __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_p, __pyx_t_9);
  6540. __pyx_t_9 = 0;
  6541. __pyx_t_9 = __Pyx_PySequence_Tuple(__pyx_8genexpr3__pyx_v_p); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 545, __pyx_L10_error)
  6542. __Pyx_GOTREF(__pyx_t_9);
  6543. __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)(&PyComplex_Type)), __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 545, __pyx_L10_error)
  6544. __Pyx_GOTREF(__pyx_t_10);
  6545. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6546. if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_10))) __PYX_ERR(0, 545, __pyx_L10_error)
  6547. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  6548. }
  6549. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6550. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p); __pyx_8genexpr3__pyx_v_p = 0;
  6551. goto __pyx_L14_exit_scope;
  6552. __pyx_L10_error:;
  6553. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p); __pyx_8genexpr3__pyx_v_p = 0;
  6554. goto __pyx_L5_error;
  6555. __pyx_L14_exit_scope:;
  6556. } /* exit inner scope */
  6557. if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 545, __pyx_L5_error)
  6558. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6559. }
  6560. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6561. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_curve); __pyx_8genexpr2__pyx_v_curve = 0;
  6562. goto __pyx_L16_exit_scope;
  6563. __pyx_L5_error:;
  6564. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_curve); __pyx_8genexpr2__pyx_v_curve = 0;
  6565. goto __pyx_L1_error;
  6566. __pyx_L16_exit_scope:;
  6567. } /* exit inner scope */
  6568. __Pyx_DECREF_SET(__pyx_v_curves, __pyx_t_1);
  6569. __pyx_t_1 = 0;
  6570. /* "fontTools/cu2qu/cu2qu.py":546
  6571. *
  6572. * curves = [[complex(*p) for p in curve] for curve in curves]
  6573. * if len(max_errors) != len(curves): # <<<<<<<<<<<<<<
  6574. * raise ValueError("max_errors must match the number of curves")
  6575. * if not curves:
  6576. */
  6577. __pyx_t_3 = PyObject_Length(__pyx_v_max_errors); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 546, __pyx_L1_error)
  6578. __pyx_t_7 = PyObject_Length(__pyx_v_curves); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 546, __pyx_L1_error)
  6579. __pyx_t_11 = (__pyx_t_3 != __pyx_t_7);
  6580. if (unlikely(__pyx_t_11)) {
  6581. /* "fontTools/cu2qu/cu2qu.py":547
  6582. * curves = [[complex(*p) for p in curve] for curve in curves]
  6583. * if len(max_errors) != len(curves):
  6584. * raise ValueError("max_errors must match the number of curves") # <<<<<<<<<<<<<<
  6585. * if not curves:
  6586. * return []
  6587. */
  6588. __pyx_t_2 = NULL;
  6589. __pyx_t_12 = 1;
  6590. {
  6591. PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_max_errors_must_match_the_number};
  6592. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_ValueError)), __pyx_callargs+__pyx_t_12, (2-__pyx_t_12) | (__pyx_t_12*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  6593. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  6594. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 547, __pyx_L1_error)
  6595. __Pyx_GOTREF(__pyx_t_1);
  6596. }
  6597. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  6598. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6599. __PYX_ERR(0, 547, __pyx_L1_error)
  6600. /* "fontTools/cu2qu/cu2qu.py":546
  6601. *
  6602. * curves = [[complex(*p) for p in curve] for curve in curves]
  6603. * if len(max_errors) != len(curves): # <<<<<<<<<<<<<<
  6604. * raise ValueError("max_errors must match the number of curves")
  6605. * if not curves:
  6606. */
  6607. }
  6608. /* "fontTools/cu2qu/cu2qu.py":548
  6609. * if len(max_errors) != len(curves):
  6610. * raise ValueError("max_errors must match the number of curves")
  6611. * if not curves: # <<<<<<<<<<<<<<
  6612. * return []
  6613. *
  6614. */
  6615. __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_curves); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 548, __pyx_L1_error)
  6616. __pyx_t_13 = (!__pyx_t_11);
  6617. if (__pyx_t_13) {
  6618. /* "fontTools/cu2qu/cu2qu.py":549
  6619. * raise ValueError("max_errors must match the number of curves")
  6620. * if not curves:
  6621. * return [] # <<<<<<<<<<<<<<
  6622. *
  6623. * l = len(curves)
  6624. */
  6625. __Pyx_XDECREF(__pyx_r);
  6626. __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 549, __pyx_L1_error)
  6627. __Pyx_GOTREF(__pyx_t_1);
  6628. __pyx_r = __pyx_t_1;
  6629. __pyx_t_1 = 0;
  6630. goto __pyx_L0;
  6631. /* "fontTools/cu2qu/cu2qu.py":548
  6632. * if len(max_errors) != len(curves):
  6633. * raise ValueError("max_errors must match the number of curves")
  6634. * if not curves: # <<<<<<<<<<<<<<
  6635. * return []
  6636. *
  6637. */
  6638. }
  6639. /* "fontTools/cu2qu/cu2qu.py":551
  6640. * return []
  6641. *
  6642. * l = len(curves) # <<<<<<<<<<<<<<
  6643. * splines = [None] * l
  6644. * last_i = i = 0
  6645. */
  6646. __pyx_t_7 = PyObject_Length(__pyx_v_curves); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 551, __pyx_L1_error)
  6647. __pyx_v_l = __pyx_t_7;
  6648. /* "fontTools/cu2qu/cu2qu.py":552
  6649. *
  6650. * l = len(curves)
  6651. * splines = [None] * l # <<<<<<<<<<<<<<
  6652. * last_i = i = 0
  6653. * n = 1
  6654. */
  6655. __pyx_t_1 = PyList_New(1 * ((__pyx_v_l<0) ? 0:__pyx_v_l)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 552, __pyx_L1_error)
  6656. __Pyx_GOTREF(__pyx_t_1);
  6657. { Py_ssize_t __pyx_temp;
  6658. for (__pyx_temp=0; __pyx_temp < __pyx_v_l; __pyx_temp++) {
  6659. __Pyx_INCREF(Py_None);
  6660. __Pyx_GIVEREF(Py_None);
  6661. if (__Pyx_PyList_SET_ITEM(__pyx_t_1, __pyx_temp, Py_None) != (0)) __PYX_ERR(0, 552, __pyx_L1_error);
  6662. }
  6663. }
  6664. __pyx_v_splines = ((PyObject*)__pyx_t_1);
  6665. __pyx_t_1 = 0;
  6666. /* "fontTools/cu2qu/cu2qu.py":553
  6667. * l = len(curves)
  6668. * splines = [None] * l
  6669. * last_i = i = 0 # <<<<<<<<<<<<<<
  6670. * n = 1
  6671. * while True:
  6672. */
  6673. __pyx_v_last_i = 0;
  6674. __pyx_v_i = 0;
  6675. /* "fontTools/cu2qu/cu2qu.py":554
  6676. * splines = [None] * l
  6677. * last_i = i = 0
  6678. * n = 1 # <<<<<<<<<<<<<<
  6679. * while True:
  6680. * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic)
  6681. */
  6682. __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
  6683. __pyx_v_n = __pyx_mstate_global->__pyx_int_1;
  6684. /* "fontTools/cu2qu/cu2qu.py":555
  6685. * last_i = i = 0
  6686. * n = 1
  6687. * while True: # <<<<<<<<<<<<<<
  6688. * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic)
  6689. * if spline is None:
  6690. */
  6691. while (1) {
  6692. /* "fontTools/cu2qu/cu2qu.py":556
  6693. * n = 1
  6694. * while True:
  6695. * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) # <<<<<<<<<<<<<<
  6696. * if spline is None:
  6697. * if n == MAX_N:
  6698. */
  6699. __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, 556, __pyx_L1_error)
  6700. __Pyx_GOTREF(__pyx_t_1);
  6701. __pyx_t_14 = __Pyx_PyLong_As_int(__pyx_v_n); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 556, __pyx_L1_error)
  6702. __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, 556, __pyx_L1_error)
  6703. __Pyx_GOTREF(__pyx_t_2);
  6704. __pyx_t_15 = __Pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_15 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 556, __pyx_L1_error)
  6705. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6706. __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(__pyx_t_1, __pyx_t_14, __pyx_t_15, __pyx_v_all_quadratic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 556, __pyx_L1_error)
  6707. __Pyx_GOTREF(__pyx_t_2);
  6708. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6709. __Pyx_XDECREF_SET(__pyx_v_spline, __pyx_t_2);
  6710. __pyx_t_2 = 0;
  6711. /* "fontTools/cu2qu/cu2qu.py":557
  6712. * while True:
  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. */
  6718. __pyx_t_13 = (__pyx_v_spline == Py_None);
  6719. if (__pyx_t_13) {
  6720. /* "fontTools/cu2qu/cu2qu.py":558
  6721. * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic)
  6722. * if spline is None:
  6723. * if n == MAX_N: # <<<<<<<<<<<<<<
  6724. * break
  6725. * n += 1
  6726. */
  6727. __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_MAX_N); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 558, __pyx_L1_error)
  6728. __Pyx_GOTREF(__pyx_t_2);
  6729. __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, 558, __pyx_L1_error)
  6730. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6731. __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 558, __pyx_L1_error)
  6732. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6733. if (__pyx_t_13) {
  6734. /* "fontTools/cu2qu/cu2qu.py":559
  6735. * if spline is None:
  6736. * if n == MAX_N:
  6737. * break # <<<<<<<<<<<<<<
  6738. * n += 1
  6739. * last_i = i
  6740. */
  6741. goto __pyx_L20_break;
  6742. /* "fontTools/cu2qu/cu2qu.py":558
  6743. * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic)
  6744. * if spline is None:
  6745. * if n == MAX_N: # <<<<<<<<<<<<<<
  6746. * break
  6747. * n += 1
  6748. */
  6749. }
  6750. /* "fontTools/cu2qu/cu2qu.py":560
  6751. * if n == MAX_N:
  6752. * break
  6753. * n += 1 # <<<<<<<<<<<<<<
  6754. * last_i = i
  6755. * continue
  6756. */
  6757. __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, 560, __pyx_L1_error)
  6758. __Pyx_GOTREF(__pyx_t_1);
  6759. __Pyx_DECREF_SET(__pyx_v_n, __pyx_t_1);
  6760. __pyx_t_1 = 0;
  6761. /* "fontTools/cu2qu/cu2qu.py":561
  6762. * break
  6763. * n += 1
  6764. * last_i = i # <<<<<<<<<<<<<<
  6765. * continue
  6766. * splines[i] = spline
  6767. */
  6768. __pyx_v_last_i = __pyx_v_i;
  6769. /* "fontTools/cu2qu/cu2qu.py":562
  6770. * n += 1
  6771. * last_i = i
  6772. * continue # <<<<<<<<<<<<<<
  6773. * splines[i] = spline
  6774. * i = (i + 1) % l
  6775. */
  6776. goto __pyx_L19_continue;
  6777. /* "fontTools/cu2qu/cu2qu.py":557
  6778. * while True:
  6779. * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic)
  6780. * if spline is None: # <<<<<<<<<<<<<<
  6781. * if n == MAX_N:
  6782. * break
  6783. */
  6784. }
  6785. /* "fontTools/cu2qu/cu2qu.py":563
  6786. * last_i = i
  6787. * continue
  6788. * splines[i] = spline # <<<<<<<<<<<<<<
  6789. * i = (i + 1) % l
  6790. * if i == last_i:
  6791. */
  6792. 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, 563, __pyx_L1_error)
  6793. /* "fontTools/cu2qu/cu2qu.py":564
  6794. * continue
  6795. * splines[i] = spline
  6796. * i = (i + 1) % l # <<<<<<<<<<<<<<
  6797. * if i == last_i:
  6798. * # done. go home
  6799. */
  6800. __pyx_t_16 = (__pyx_v_i + 1);
  6801. if (unlikely(__pyx_v_l == 0)) {
  6802. PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
  6803. __PYX_ERR(0, 564, __pyx_L1_error)
  6804. }
  6805. __pyx_v_i = __Pyx_mod_long(__pyx_t_16, __pyx_v_l, 0);
  6806. /* "fontTools/cu2qu/cu2qu.py":565
  6807. * splines[i] = spline
  6808. * i = (i + 1) % l
  6809. * if i == last_i: # <<<<<<<<<<<<<<
  6810. * # done. go home
  6811. * return [[(s.real, s.imag) for s in spline] for spline in splines]
  6812. */
  6813. __pyx_t_13 = (__pyx_v_i == __pyx_v_last_i);
  6814. if (__pyx_t_13) {
  6815. /* "fontTools/cu2qu/cu2qu.py":567
  6816. * if i == last_i:
  6817. * # done. go home
  6818. * return [[(s.real, s.imag) for s in spline] for spline in splines] # <<<<<<<<<<<<<<
  6819. *
  6820. * raise ApproxNotFoundError(curves)
  6821. */
  6822. __Pyx_XDECREF(__pyx_r);
  6823. { /* enter inner scope */
  6824. __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 567, __pyx_L26_error)
  6825. __Pyx_GOTREF(__pyx_t_1);
  6826. __pyx_t_2 = __pyx_v_splines; __Pyx_INCREF(__pyx_t_2);
  6827. __pyx_t_7 = 0;
  6828. for (;;) {
  6829. {
  6830. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
  6831. #if !CYTHON_ASSUME_SAFE_SIZE
  6832. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 567, __pyx_L26_error)
  6833. #endif
  6834. if (__pyx_t_7 >= __pyx_temp) break;
  6835. }
  6836. __pyx_t_5 = __Pyx_PyList_GetItemRefFast(__pyx_t_2, __pyx_t_7, __Pyx_ReferenceSharing_OwnStrongReference);
  6837. ++__pyx_t_7;
  6838. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 567, __pyx_L26_error)
  6839. __Pyx_GOTREF(__pyx_t_5);
  6840. __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_spline, __pyx_t_5);
  6841. __pyx_t_5 = 0;
  6842. { /* enter inner scope */
  6843. __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 567, __pyx_L31_error)
  6844. __Pyx_GOTREF(__pyx_t_5);
  6845. if (likely(PyList_CheckExact(__pyx_8genexpr4__pyx_v_spline)) || PyTuple_CheckExact(__pyx_8genexpr4__pyx_v_spline)) {
  6846. __pyx_t_6 = __pyx_8genexpr4__pyx_v_spline; __Pyx_INCREF(__pyx_t_6);
  6847. __pyx_t_3 = 0;
  6848. __pyx_t_4 = NULL;
  6849. } else {
  6850. __pyx_t_3 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_8genexpr4__pyx_v_spline); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 567, __pyx_L31_error)
  6851. __Pyx_GOTREF(__pyx_t_6);
  6852. __pyx_t_4 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 567, __pyx_L31_error)
  6853. }
  6854. for (;;) {
  6855. if (likely(!__pyx_t_4)) {
  6856. if (likely(PyList_CheckExact(__pyx_t_6))) {
  6857. {
  6858. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  6859. #if !CYTHON_ASSUME_SAFE_SIZE
  6860. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 567, __pyx_L31_error)
  6861. #endif
  6862. if (__pyx_t_3 >= __pyx_temp) break;
  6863. }
  6864. __pyx_t_10 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_3, __Pyx_ReferenceSharing_OwnStrongReference);
  6865. ++__pyx_t_3;
  6866. } else {
  6867. {
  6868. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
  6869. #if !CYTHON_ASSUME_SAFE_SIZE
  6870. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 567, __pyx_L31_error)
  6871. #endif
  6872. if (__pyx_t_3 >= __pyx_temp) break;
  6873. }
  6874. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6875. __pyx_t_10 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_3));
  6876. #else
  6877. __pyx_t_10 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_3);
  6878. #endif
  6879. ++__pyx_t_3;
  6880. }
  6881. if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 567, __pyx_L31_error)
  6882. } else {
  6883. __pyx_t_10 = __pyx_t_4(__pyx_t_6);
  6884. if (unlikely(!__pyx_t_10)) {
  6885. PyObject* exc_type = PyErr_Occurred();
  6886. if (exc_type) {
  6887. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 567, __pyx_L31_error)
  6888. PyErr_Clear();
  6889. }
  6890. break;
  6891. }
  6892. }
  6893. __Pyx_GOTREF(__pyx_t_10);
  6894. __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_s, __pyx_t_10);
  6895. __pyx_t_10 = 0;
  6896. __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, 567, __pyx_L31_error)
  6897. __Pyx_GOTREF(__pyx_t_10);
  6898. __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, 567, __pyx_L31_error)
  6899. __Pyx_GOTREF(__pyx_t_9);
  6900. __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 567, __pyx_L31_error)
  6901. __Pyx_GOTREF(__pyx_t_17);
  6902. __Pyx_GIVEREF(__pyx_t_10);
  6903. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_10) != (0)) __PYX_ERR(0, 567, __pyx_L31_error);
  6904. __Pyx_GIVEREF(__pyx_t_9);
  6905. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_t_9) != (0)) __PYX_ERR(0, 567, __pyx_L31_error);
  6906. __pyx_t_10 = 0;
  6907. __pyx_t_9 = 0;
  6908. if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_17))) __PYX_ERR(0, 567, __pyx_L31_error)
  6909. __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  6910. }
  6911. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6912. __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_s); __pyx_8genexpr5__pyx_v_s = 0;
  6913. goto __pyx_L35_exit_scope;
  6914. __pyx_L31_error:;
  6915. __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_s); __pyx_8genexpr5__pyx_v_s = 0;
  6916. goto __pyx_L26_error;
  6917. __pyx_L35_exit_scope:;
  6918. } /* exit inner scope */
  6919. if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 567, __pyx_L26_error)
  6920. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6921. }
  6922. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6923. __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_spline); __pyx_8genexpr4__pyx_v_spline = 0;
  6924. goto __pyx_L37_exit_scope;
  6925. __pyx_L26_error:;
  6926. __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_spline); __pyx_8genexpr4__pyx_v_spline = 0;
  6927. goto __pyx_L1_error;
  6928. __pyx_L37_exit_scope:;
  6929. } /* exit inner scope */
  6930. __pyx_r = __pyx_t_1;
  6931. __pyx_t_1 = 0;
  6932. goto __pyx_L0;
  6933. /* "fontTools/cu2qu/cu2qu.py":565
  6934. * splines[i] = spline
  6935. * i = (i + 1) % l
  6936. * if i == last_i: # <<<<<<<<<<<<<<
  6937. * # done. go home
  6938. * return [[(s.real, s.imag) for s in spline] for spline in splines]
  6939. */
  6940. }
  6941. __pyx_L19_continue:;
  6942. }
  6943. __pyx_L20_break:;
  6944. /* "fontTools/cu2qu/cu2qu.py":569
  6945. * return [[(s.real, s.imag) for s in spline] for spline in splines]
  6946. *
  6947. * raise ApproxNotFoundError(curves) # <<<<<<<<<<<<<<
  6948. */
  6949. __pyx_t_2 = NULL;
  6950. __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_ApproxNotFoundError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 569, __pyx_L1_error)
  6951. __Pyx_GOTREF(__pyx_t_5);
  6952. __pyx_t_12 = 1;
  6953. #if CYTHON_UNPACK_METHODS
  6954. if (unlikely(PyMethod_Check(__pyx_t_5))) {
  6955. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
  6956. assert(__pyx_t_2);
  6957. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
  6958. __Pyx_INCREF(__pyx_t_2);
  6959. __Pyx_INCREF(__pyx__function);
  6960. __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
  6961. __pyx_t_12 = 0;
  6962. }
  6963. #endif
  6964. {
  6965. PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_curves};
  6966. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_12, (2-__pyx_t_12) | (__pyx_t_12*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  6967. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  6968. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6969. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 569, __pyx_L1_error)
  6970. __Pyx_GOTREF(__pyx_t_1);
  6971. }
  6972. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  6973. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6974. __PYX_ERR(0, 569, __pyx_L1_error)
  6975. /* "fontTools/cu2qu/cu2qu.py":505
  6976. *
  6977. *
  6978. * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) # <<<<<<<<<<<<<<
  6979. * @cython.locals(all_quadratic=cython.int)
  6980. * def curves_to_quadratic(curves, max_errors, all_quadratic=True):
  6981. */
  6982. /* function exit code */
  6983. __pyx_L1_error:;
  6984. __Pyx_XDECREF(__pyx_t_1);
  6985. __Pyx_XDECREF(__pyx_t_2);
  6986. __Pyx_XDECREF(__pyx_t_5);
  6987. __Pyx_XDECREF(__pyx_t_6);
  6988. __Pyx_XDECREF(__pyx_t_9);
  6989. __Pyx_XDECREF(__pyx_t_10);
  6990. __Pyx_XDECREF(__pyx_t_17);
  6991. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curves_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6992. __pyx_r = NULL;
  6993. __pyx_L0:;
  6994. __Pyx_XDECREF(__pyx_v_splines);
  6995. __Pyx_XDECREF(__pyx_v_n);
  6996. __Pyx_XDECREF(__pyx_v_spline);
  6997. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_curve);
  6998. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p);
  6999. __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_spline);
  7000. __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_s);
  7001. __Pyx_XDECREF(__pyx_v_curves);
  7002. __Pyx_XGIVEREF(__pyx_r);
  7003. __Pyx_RefNannyFinishContext();
  7004. return __pyx_r;
  7005. }
  7006. /* #### Code section: module_exttypes ### */
  7007. 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) {
  7008. PyObject *o;
  7009. #if CYTHON_USE_FREELISTS
  7010. 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))))
  7011. {
  7012. 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];
  7013. #if CYTHON_USE_TYPE_SPECS
  7014. Py_DECREF(Py_TYPE(o));
  7015. #endif
  7016. memset(o, 0, sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen));
  7017. #if CYTHON_COMPILING_IN_LIMITED_API
  7018. (void) PyObject_Init(o, t);
  7019. #else
  7020. (void) PyObject_INIT(o, t);
  7021. #endif
  7022. } else
  7023. #endif
  7024. {
  7025. o = __Pyx_AllocateExtensionType(t, 1);
  7026. if (unlikely(!o)) return 0;
  7027. }
  7028. return o;
  7029. }
  7030. static void __pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(PyObject *o) {
  7031. #if CYTHON_USE_TP_FINALIZE
  7032. if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && (!PyType_IS_GC(Py_TYPE(o)) || !__Pyx_PyObject_GC_IsFinalized(o))) {
  7033. if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen) {
  7034. if (PyObject_CallFinalizerFromDealloc(o)) return;
  7035. }
  7036. }
  7037. #endif
  7038. #if CYTHON_USE_FREELISTS
  7039. 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))))
  7040. {
  7041. __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);
  7042. } else
  7043. #endif
  7044. {
  7045. PyTypeObject *tp = Py_TYPE(o);
  7046. #if CYTHON_USE_TYPE_SLOTS
  7047. (*tp->tp_free)(o);
  7048. #else
  7049. {
  7050. freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
  7051. if (tp_free) tp_free(o);
  7052. }
  7053. #endif
  7054. #if CYTHON_USE_TYPE_SPECS
  7055. Py_DECREF(tp);
  7056. #endif
  7057. }
  7058. }
  7059. #if CYTHON_USE_TYPE_SPECS
  7060. static PyType_Slot __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen_slots[] = {
  7061. {Py_tp_dealloc, (void *)__pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen},
  7062. {Py_tp_new, (void *)__pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen},
  7063. {0, 0},
  7064. };
  7065. static PyType_Spec __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen_spec = {
  7066. "fontTools.cu2qu.cu2qu.__pyx_scope_struct___split_cubic_into_n_gen",
  7067. sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen),
  7068. 0,
  7069. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER,
  7070. __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen_slots,
  7071. };
  7072. #else
  7073. static PyTypeObject __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen = {
  7074. PyVarObject_HEAD_INIT(0, 0)
  7075. "fontTools.cu2qu.cu2qu.""__pyx_scope_struct___split_cubic_into_n_gen", /*tp_name*/
  7076. sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen), /*tp_basicsize*/
  7077. 0, /*tp_itemsize*/
  7078. __pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen, /*tp_dealloc*/
  7079. 0, /*tp_vectorcall_offset*/
  7080. 0, /*tp_getattr*/
  7081. 0, /*tp_setattr*/
  7082. 0, /*tp_as_async*/
  7083. 0, /*tp_repr*/
  7084. 0, /*tp_as_number*/
  7085. 0, /*tp_as_sequence*/
  7086. 0, /*tp_as_mapping*/
  7087. 0, /*tp_hash*/
  7088. 0, /*tp_call*/
  7089. 0, /*tp_str*/
  7090. 0, /*tp_getattro*/
  7091. 0, /*tp_setattro*/
  7092. 0, /*tp_as_buffer*/
  7093. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  7094. 0, /*tp_doc*/
  7095. 0, /*tp_traverse*/
  7096. 0, /*tp_clear*/
  7097. 0, /*tp_richcompare*/
  7098. 0, /*tp_weaklistoffset*/
  7099. 0, /*tp_iter*/
  7100. 0, /*tp_iternext*/
  7101. 0, /*tp_methods*/
  7102. 0, /*tp_members*/
  7103. 0, /*tp_getset*/
  7104. 0, /*tp_base*/
  7105. 0, /*tp_dict*/
  7106. 0, /*tp_descr_get*/
  7107. 0, /*tp_descr_set*/
  7108. #if !CYTHON_USE_TYPE_SPECS
  7109. 0, /*tp_dictoffset*/
  7110. #endif
  7111. 0, /*tp_init*/
  7112. 0, /*tp_alloc*/
  7113. __pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen, /*tp_new*/
  7114. 0, /*tp_free*/
  7115. 0, /*tp_is_gc*/
  7116. 0, /*tp_bases*/
  7117. 0, /*tp_mro*/
  7118. 0, /*tp_cache*/
  7119. 0, /*tp_subclasses*/
  7120. 0, /*tp_weaklist*/
  7121. 0, /*tp_del*/
  7122. 0, /*tp_version_tag*/
  7123. #if CYTHON_USE_TP_FINALIZE
  7124. 0, /*tp_finalize*/
  7125. #else
  7126. NULL, /*tp_finalize*/
  7127. #endif
  7128. #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  7129. 0, /*tp_vectorcall*/
  7130. #endif
  7131. #if __PYX_NEED_TP_PRINT_SLOT == 1
  7132. 0, /*tp_print*/
  7133. #endif
  7134. #if PY_VERSION_HEX >= 0x030C0000
  7135. 0, /*tp_watched*/
  7136. #endif
  7137. #if PY_VERSION_HEX >= 0x030d00A4
  7138. 0, /*tp_versions_used*/
  7139. #endif
  7140. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  7141. 0, /*tp_pypy_flags*/
  7142. #endif
  7143. };
  7144. #endif
  7145. static PyMethodDef __pyx_methods[] = {
  7146. {0, 0, 0, 0}
  7147. };
  7148. /* #### Code section: initfunc_declarations ### */
  7149. static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7150. static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7151. static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void); /*proto*/
  7152. static CYTHON_SMALL_CODE int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7153. static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7154. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7155. static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7156. static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7157. static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7158. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7159. static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7160. static CYTHON_SMALL_CODE int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7161. /* #### Code section: init_module ### */
  7162. static int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate) {
  7163. __Pyx_RefNannyDeclarations
  7164. CYTHON_UNUSED_VAR(__pyx_mstate);
  7165. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  7166. /*--- Global init code ---*/
  7167. __Pyx_RefNannyFinishContext();
  7168. return 0;
  7169. }
  7170. static int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate) {
  7171. __Pyx_RefNannyDeclarations
  7172. CYTHON_UNUSED_VAR(__pyx_mstate);
  7173. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  7174. /*--- Variable export code ---*/
  7175. __Pyx_RefNannyFinishContext();
  7176. return 0;
  7177. }
  7178. static int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate) {
  7179. __Pyx_RefNannyDeclarations
  7180. CYTHON_UNUSED_VAR(__pyx_mstate);
  7181. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  7182. /*--- Function export code ---*/
  7183. __Pyx_RefNannyFinishContext();
  7184. return 0;
  7185. }
  7186. static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) {
  7187. __Pyx_RefNannyDeclarations
  7188. CYTHON_UNUSED_VAR(__pyx_mstate);
  7189. int __pyx_lineno = 0;
  7190. const char *__pyx_filename = NULL;
  7191. int __pyx_clineno = 0;
  7192. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  7193. /*--- Type init code ---*/
  7194. #if CYTHON_USE_TYPE_SPECS
  7195. __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)
  7196. 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)
  7197. #else
  7198. __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;
  7199. #endif
  7200. #if !CYTHON_COMPILING_IN_LIMITED_API
  7201. #endif
  7202. #if !CYTHON_USE_TYPE_SPECS
  7203. 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)
  7204. #endif
  7205. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  7206. PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen);
  7207. #endif
  7208. #if !CYTHON_COMPILING_IN_LIMITED_API
  7209. 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)) {
  7210. __pyx_mstate->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen->tp_getattro = PyObject_GenericGetAttr;
  7211. }
  7212. #endif
  7213. __Pyx_RefNannyFinishContext();
  7214. return 0;
  7215. __pyx_L1_error:;
  7216. __Pyx_RefNannyFinishContext();
  7217. return -1;
  7218. }
  7219. static int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate) {
  7220. __Pyx_RefNannyDeclarations
  7221. CYTHON_UNUSED_VAR(__pyx_mstate);
  7222. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  7223. /*--- Type import code ---*/
  7224. __Pyx_RefNannyFinishContext();
  7225. return 0;
  7226. }
  7227. static int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate) {
  7228. __Pyx_RefNannyDeclarations
  7229. CYTHON_UNUSED_VAR(__pyx_mstate);
  7230. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  7231. /*--- Variable import code ---*/
  7232. __Pyx_RefNannyFinishContext();
  7233. return 0;
  7234. }
  7235. static int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate) {
  7236. __Pyx_RefNannyDeclarations
  7237. CYTHON_UNUSED_VAR(__pyx_mstate);
  7238. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  7239. /*--- Function import code ---*/
  7240. __Pyx_RefNannyFinishContext();
  7241. return 0;
  7242. }
  7243. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7244. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  7245. static int __pyx_pymod_exec_cu2qu(PyObject* module); /*proto*/
  7246. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  7247. {Py_mod_create, (void*)__pyx_pymod_create},
  7248. {Py_mod_exec, (void*)__pyx_pymod_exec_cu2qu},
  7249. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  7250. {Py_mod_gil, __Pyx_FREETHREADING_COMPATIBLE},
  7251. #endif
  7252. #if PY_VERSION_HEX >= 0x030C0000 && CYTHON_USE_MODULE_STATE
  7253. {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
  7254. #endif
  7255. {0, NULL}
  7256. };
  7257. #endif
  7258. #ifdef __cplusplus
  7259. namespace {
  7260. struct PyModuleDef __pyx_moduledef =
  7261. #else
  7262. static struct PyModuleDef __pyx_moduledef =
  7263. #endif
  7264. {
  7265. PyModuleDef_HEAD_INIT,
  7266. "cu2qu",
  7267. 0, /* m_doc */
  7268. #if CYTHON_USE_MODULE_STATE
  7269. sizeof(__pyx_mstatetype), /* m_size */
  7270. #else
  7271. (CYTHON_PEP489_MULTI_PHASE_INIT) ? 0 : -1, /* m_size */
  7272. #endif
  7273. __pyx_methods /* m_methods */,
  7274. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7275. __pyx_moduledef_slots, /* m_slots */
  7276. #else
  7277. NULL, /* m_reload */
  7278. #endif
  7279. #if CYTHON_USE_MODULE_STATE
  7280. __pyx_m_traverse, /* m_traverse */
  7281. __pyx_m_clear, /* m_clear */
  7282. NULL /* m_free */
  7283. #else
  7284. NULL, /* m_traverse */
  7285. NULL, /* m_clear */
  7286. NULL /* m_free */
  7287. #endif
  7288. };
  7289. #ifdef __cplusplus
  7290. } /* anonymous namespace */
  7291. #endif
  7292. /* PyModInitFuncType */
  7293. #ifndef CYTHON_NO_PYINIT_EXPORT
  7294. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  7295. #else
  7296. #ifdef __cplusplus
  7297. #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
  7298. #else
  7299. #define __Pyx_PyMODINIT_FUNC PyObject *
  7300. #endif
  7301. #endif
  7302. __Pyx_PyMODINIT_FUNC PyInit_cu2qu(void) CYTHON_SMALL_CODE; /*proto*/
  7303. __Pyx_PyMODINIT_FUNC PyInit_cu2qu(void)
  7304. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7305. {
  7306. return PyModuleDef_Init(&__pyx_moduledef);
  7307. }
  7308. /* ModuleCreationPEP489 */
  7309. #if CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\
  7310. || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000))
  7311. static PY_INT64_T __Pyx_GetCurrentInterpreterId(void) {
  7312. {
  7313. PyObject *module = PyImport_ImportModule("_interpreters"); // 3.13+ I think
  7314. if (!module) {
  7315. PyErr_Clear(); // just try the 3.8-3.12 version
  7316. module = PyImport_ImportModule("_xxsubinterpreters");
  7317. if (!module) goto bad;
  7318. }
  7319. PyObject *current = PyObject_CallMethod(module, "get_current", NULL);
  7320. Py_DECREF(module);
  7321. if (!current) goto bad;
  7322. if (PyTuple_Check(current)) {
  7323. PyObject *new_current = PySequence_GetItem(current, 0);
  7324. Py_DECREF(current);
  7325. current = new_current;
  7326. if (!new_current) goto bad;
  7327. }
  7328. long long as_c_int = PyLong_AsLongLong(current);
  7329. Py_DECREF(current);
  7330. return as_c_int;
  7331. }
  7332. bad:
  7333. PySys_WriteStderr("__Pyx_GetCurrentInterpreterId failed. Try setting the C define CYTHON_PEP489_MULTI_PHASE_INIT=0\n");
  7334. return -1;
  7335. }
  7336. #endif
  7337. #if !CYTHON_USE_MODULE_STATE
  7338. static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
  7339. static PY_INT64_T main_interpreter_id = -1;
  7340. #if CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
  7341. PY_INT64_T current_id = GraalPyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
  7342. #elif CYTHON_COMPILING_IN_GRAAL
  7343. PY_INT64_T current_id = PyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
  7344. #elif CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\
  7345. || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000))
  7346. PY_INT64_T current_id = __Pyx_GetCurrentInterpreterId();
  7347. #elif CYTHON_COMPILING_IN_LIMITED_API
  7348. PY_INT64_T current_id = PyInterpreterState_GetID(PyInterpreterState_Get());
  7349. #else
  7350. PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
  7351. #endif
  7352. if (unlikely(current_id == -1)) {
  7353. return -1;
  7354. }
  7355. if (main_interpreter_id == -1) {
  7356. main_interpreter_id = current_id;
  7357. return 0;
  7358. } else if (unlikely(main_interpreter_id != current_id)) {
  7359. PyErr_SetString(
  7360. PyExc_ImportError,
  7361. "Interpreter change detected - this module can only be loaded into one interpreter per process.");
  7362. return -1;
  7363. }
  7364. return 0;
  7365. }
  7366. #endif
  7367. 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)
  7368. {
  7369. PyObject *value = PyObject_GetAttrString(spec, from_name);
  7370. int result = 0;
  7371. if (likely(value)) {
  7372. if (allow_none || value != Py_None) {
  7373. result = PyDict_SetItemString(moddict, to_name, value);
  7374. }
  7375. Py_DECREF(value);
  7376. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  7377. PyErr_Clear();
  7378. } else {
  7379. result = -1;
  7380. }
  7381. return result;
  7382. }
  7383. static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) {
  7384. PyObject *module = NULL, *moddict, *modname;
  7385. CYTHON_UNUSED_VAR(def);
  7386. #if !CYTHON_USE_MODULE_STATE
  7387. if (__Pyx_check_single_interpreter())
  7388. return NULL;
  7389. #endif
  7390. if (__pyx_m)
  7391. return __Pyx_NewRef(__pyx_m);
  7392. modname = PyObject_GetAttrString(spec, "name");
  7393. if (unlikely(!modname)) goto bad;
  7394. module = PyModule_NewObject(modname);
  7395. Py_DECREF(modname);
  7396. if (unlikely(!module)) goto bad;
  7397. moddict = PyModule_GetDict(module);
  7398. if (unlikely(!moddict)) goto bad;
  7399. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
  7400. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
  7401. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
  7402. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
  7403. return module;
  7404. bad:
  7405. Py_XDECREF(module);
  7406. return NULL;
  7407. }
  7408. static CYTHON_SMALL_CODE int __pyx_pymod_exec_cu2qu(PyObject *__pyx_pyinit_module)
  7409. #endif
  7410. {
  7411. int stringtab_initialized = 0;
  7412. #if CYTHON_USE_MODULE_STATE
  7413. int pystate_addmodule_run = 0;
  7414. #endif
  7415. __pyx_mstatetype *__pyx_mstate = NULL;
  7416. PyObject *__pyx_t_1 = NULL;
  7417. PyObject *__pyx_t_2 = NULL;
  7418. PyObject *__pyx_t_3 = NULL;
  7419. PyObject *__pyx_t_4 = NULL;
  7420. Py_ssize_t __pyx_t_5;
  7421. PyObject *__pyx_t_6 = NULL;
  7422. double __pyx_t_7;
  7423. int __pyx_lineno = 0;
  7424. const char *__pyx_filename = NULL;
  7425. int __pyx_clineno = 0;
  7426. __Pyx_RefNannyDeclarations
  7427. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7428. if (__pyx_m) {
  7429. if (__pyx_m == __pyx_pyinit_module) return 0;
  7430. PyErr_SetString(PyExc_RuntimeError, "Module 'cu2qu' has already been imported. Re-initialisation is not supported.");
  7431. return -1;
  7432. }
  7433. #else
  7434. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  7435. #endif
  7436. /*--- Module creation code ---*/
  7437. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7438. __pyx_t_1 = __pyx_pyinit_module;
  7439. Py_INCREF(__pyx_t_1);
  7440. #else
  7441. __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  7442. #endif
  7443. #if CYTHON_USE_MODULE_STATE
  7444. {
  7445. int add_module_result = __Pyx_State_AddModule(__pyx_t_1, &__pyx_moduledef);
  7446. __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "cu2qu" pseudovariable */
  7447. if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
  7448. pystate_addmodule_run = 1;
  7449. }
  7450. #else
  7451. __pyx_m = __pyx_t_1;
  7452. #endif
  7453. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  7454. PyUnstable_Module_SetGIL(__pyx_m, Py_MOD_GIL_USED);
  7455. #endif
  7456. __pyx_mstate = __pyx_mstate_global;
  7457. CYTHON_UNUSED_VAR(__pyx_t_1);
  7458. __pyx_mstate->__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_mstate->__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  7459. Py_INCREF(__pyx_mstate->__pyx_d);
  7460. __pyx_mstate->__pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_mstate->__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  7461. __pyx_mstate->__pyx_cython_runtime = __Pyx_PyImport_AddModuleRef("cython_runtime"); if (unlikely(!__pyx_mstate->__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  7462. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_mstate->__pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7463. /* ImportRefnannyAPI */
  7464. #if CYTHON_REFNANNY
  7465. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  7466. if (!__Pyx_RefNanny) {
  7467. PyErr_Clear();
  7468. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  7469. if (!__Pyx_RefNanny)
  7470. Py_FatalError("failed to import 'refnanny' module");
  7471. }
  7472. #endif
  7473. __Pyx_RefNannySetupContext("PyInit_cu2qu", 0);
  7474. __Pyx_init_runtime_version();
  7475. 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)
  7476. __pyx_mstate->__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_mstate->__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  7477. __pyx_mstate->__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  7478. __pyx_mstate->__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  7479. /*--- Library function declarations ---*/
  7480. /*--- Initialize various global constants etc. ---*/
  7481. if (__Pyx_InitConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7482. stringtab_initialized = 1;
  7483. if (__Pyx_InitGlobals() < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7484. if (__pyx_module_is_main_fontTools__cu2qu__cu2qu) {
  7485. 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)
  7486. }
  7487. {
  7488. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  7489. if (!PyDict_GetItemString(modules, "fontTools.cu2qu.cu2qu")) {
  7490. if (unlikely((PyDict_SetItemString(modules, "fontTools.cu2qu.cu2qu", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
  7491. }
  7492. }
  7493. /*--- Builtin init code ---*/
  7494. if (__Pyx_InitCachedBuiltins(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7495. /*--- Constants init code ---*/
  7496. if (__Pyx_InitCachedConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7497. if (__Pyx_CreateCodeObjects(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7498. /*--- Global type/function init code ---*/
  7499. (void)__Pyx_modinit_global_init_code(__pyx_mstate);
  7500. (void)__Pyx_modinit_variable_export_code(__pyx_mstate);
  7501. (void)__Pyx_modinit_function_export_code(__pyx_mstate);
  7502. if (unlikely((__Pyx_modinit_type_init_code(__pyx_mstate) < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
  7503. (void)__Pyx_modinit_type_import_code(__pyx_mstate);
  7504. (void)__Pyx_modinit_variable_import_code(__pyx_mstate);
  7505. (void)__Pyx_modinit_function_import_code(__pyx_mstate);
  7506. /*--- Execution code ---*/
  7507. /* "fontTools/cu2qu/cu2qu.py":18
  7508. * # limitations under the License.
  7509. *
  7510. * try: # <<<<<<<<<<<<<<
  7511. * import cython
  7512. * except (AttributeError, ImportError):
  7513. */
  7514. {
  7515. (void)__pyx_t_1; (void)__pyx_t_2; (void)__pyx_t_3; /* mark used */
  7516. /*try:*/ {
  7517. /* "fontTools/cu2qu/cu2qu.py":19
  7518. *
  7519. * try:
  7520. * import cython # <<<<<<<<<<<<<<
  7521. * except (AttributeError, ImportError):
  7522. * # if cython not installed, use mock module with no-op decorators and types
  7523. */
  7524. }
  7525. }
  7526. /* "fontTools/cu2qu/cu2qu.py":23
  7527. * # if cython not installed, use mock module with no-op decorators and types
  7528. * from fontTools.misc import cython
  7529. * COMPILED = cython.compiled # <<<<<<<<<<<<<<
  7530. *
  7531. * import math
  7532. */
  7533. 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)
  7534. /* "fontTools/cu2qu/cu2qu.py":25
  7535. * COMPILED = cython.compiled
  7536. *
  7537. * import math # <<<<<<<<<<<<<<
  7538. *
  7539. * from .errors import Error as Cu2QuError, ApproxNotFoundError
  7540. */
  7541. __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)
  7542. __pyx_t_4 = __pyx_t_3;
  7543. __Pyx_GOTREF(__pyx_t_4);
  7544. 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)
  7545. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7546. /* "fontTools/cu2qu/cu2qu.py":27
  7547. * import math
  7548. *
  7549. * from .errors import Error as Cu2QuError, ApproxNotFoundError # <<<<<<<<<<<<<<
  7550. *
  7551. *
  7552. */
  7553. {
  7554. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_Error,__pyx_mstate_global->__pyx_n_u_ApproxNotFoundError};
  7555. __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)
  7556. }
  7557. __pyx_t_4 = __pyx_t_3;
  7558. __Pyx_GOTREF(__pyx_t_4);
  7559. {
  7560. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_Error,__pyx_mstate_global->__pyx_n_u_ApproxNotFoundError};
  7561. for (__pyx_t_5=0; __pyx_t_5 < 2; __pyx_t_5++) {
  7562. __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)
  7563. __Pyx_GOTREF(__pyx_t_6);
  7564. switch (__pyx_t_5) {
  7565. case 0:
  7566. 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)
  7567. break;
  7568. default:;
  7569. 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)
  7570. }
  7571. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7572. }
  7573. }
  7574. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7575. /* "fontTools/cu2qu/cu2qu.py":30
  7576. *
  7577. *
  7578. * __all__ = ["curve_to_quadratic", "curves_to_quadratic"] # <<<<<<<<<<<<<<
  7579. *
  7580. * MAX_N = 100
  7581. */
  7582. __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)
  7583. __Pyx_GOTREF(__pyx_t_4);
  7584. 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)
  7585. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7586. /* "fontTools/cu2qu/cu2qu.py":32
  7587. * __all__ = ["curve_to_quadratic", "curves_to_quadratic"]
  7588. *
  7589. * MAX_N = 100 # <<<<<<<<<<<<<<
  7590. *
  7591. * NAN = float("NaN")
  7592. */
  7593. 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)
  7594. /* "fontTools/cu2qu/cu2qu.py":34
  7595. * MAX_N = 100
  7596. *
  7597. * NAN = float("NaN") # <<<<<<<<<<<<<<
  7598. *
  7599. *
  7600. */
  7601. __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)
  7602. __pyx_t_4 = PyFloat_FromDouble(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 34, __pyx_L1_error)
  7603. __Pyx_GOTREF(__pyx_t_4);
  7604. 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)
  7605. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7606. /* "fontTools/cu2qu/cu2qu.py":150
  7607. *
  7608. *
  7609. * @cython.locals( # <<<<<<<<<<<<<<
  7610. * p0=cython.complex,
  7611. * p1=cython.complex,
  7612. */
  7613. __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)
  7614. __Pyx_GOTREF(__pyx_t_4);
  7615. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  7616. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  7617. #endif
  7618. 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)
  7619. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7620. /* "fontTools/cu2qu/cu2qu.py":471
  7621. * @cython.locals(n=cython.int)
  7622. * @cython.locals(all_quadratic=cython.int)
  7623. * def curve_to_quadratic(curve, max_err, all_quadratic=True): # <<<<<<<<<<<<<<
  7624. * """Approximate a cubic Bezier curve with a spline of n quadratics.
  7625. *
  7626. */
  7627. __pyx_t_4 = __Pyx_PyBool_FromLong(((int)1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 471, __pyx_L1_error)
  7628. __Pyx_GOTREF(__pyx_t_4);
  7629. /* "fontTools/cu2qu/cu2qu.py":468
  7630. *
  7631. *
  7632. * @cython.locals(max_err=cython.double) # <<<<<<<<<<<<<<
  7633. * @cython.locals(n=cython.int)
  7634. * @cython.locals(all_quadratic=cython.int)
  7635. */
  7636. __pyx_t_6 = PyTuple_Pack(1, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 468, __pyx_L1_error)
  7637. __Pyx_GOTREF(__pyx_t_6);
  7638. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7639. __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)
  7640. __Pyx_GOTREF(__pyx_t_4);
  7641. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  7642. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  7643. #endif
  7644. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_t_6);
  7645. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7646. 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)
  7647. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7648. /* "fontTools/cu2qu/cu2qu.py":507
  7649. * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int)
  7650. * @cython.locals(all_quadratic=cython.int)
  7651. * def curves_to_quadratic(curves, max_errors, all_quadratic=True): # <<<<<<<<<<<<<<
  7652. * """Return quadratic Bezier splines approximating the input cubic Beziers.
  7653. *
  7654. */
  7655. __pyx_t_4 = __Pyx_PyBool_FromLong(((int)1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 507, __pyx_L1_error)
  7656. __Pyx_GOTREF(__pyx_t_4);
  7657. /* "fontTools/cu2qu/cu2qu.py":505
  7658. *
  7659. *
  7660. * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) # <<<<<<<<<<<<<<
  7661. * @cython.locals(all_quadratic=cython.int)
  7662. * def curves_to_quadratic(curves, max_errors, all_quadratic=True):
  7663. */
  7664. __pyx_t_6 = PyTuple_Pack(1, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 505, __pyx_L1_error)
  7665. __Pyx_GOTREF(__pyx_t_6);
  7666. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7667. __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, 505, __pyx_L1_error)
  7668. __Pyx_GOTREF(__pyx_t_4);
  7669. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  7670. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  7671. #endif
  7672. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_t_6);
  7673. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7674. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_curves_to_quadratic, __pyx_t_4) < (0)) __PYX_ERR(0, 505, __pyx_L1_error)
  7675. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7676. /* "fontTools/cu2qu/cu2qu.py":1
  7677. * # cython: language_level=3 # <<<<<<<<<<<<<<
  7678. * # distutils: define_macros=CYTHON_TRACE_NOGIL=1
  7679. *
  7680. */
  7681. __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  7682. __Pyx_GOTREF(__pyx_t_4);
  7683. if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_curves_to_quadratic_line_505, __pyx_mstate_global->__pyx_kp_u_Return_quadratic_Bezier_splines) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7684. 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)
  7685. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7686. /*--- Wrapped vars code ---*/
  7687. goto __pyx_L0;
  7688. __pyx_L1_error:;
  7689. __Pyx_XDECREF(__pyx_t_4);
  7690. __Pyx_XDECREF(__pyx_t_6);
  7691. if (__pyx_m) {
  7692. if (__pyx_mstate->__pyx_d && stringtab_initialized) {
  7693. __Pyx_AddTraceback("init fontTools.cu2qu.cu2qu", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7694. }
  7695. #if !CYTHON_USE_MODULE_STATE
  7696. Py_CLEAR(__pyx_m);
  7697. #else
  7698. Py_DECREF(__pyx_m);
  7699. if (pystate_addmodule_run) {
  7700. PyObject *tp, *value, *tb;
  7701. PyErr_Fetch(&tp, &value, &tb);
  7702. PyState_RemoveModule(&__pyx_moduledef);
  7703. PyErr_Restore(tp, value, tb);
  7704. }
  7705. #endif
  7706. } else if (!PyErr_Occurred()) {
  7707. PyErr_SetString(PyExc_ImportError, "init fontTools.cu2qu.cu2qu");
  7708. }
  7709. __pyx_L0:;
  7710. __Pyx_RefNannyFinishContext();
  7711. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7712. return (__pyx_m != NULL) ? 0 : -1;
  7713. #else
  7714. return __pyx_m;
  7715. #endif
  7716. }
  7717. /* #### Code section: pystring_table ### */
  7718. /* #### Code section: cached_builtins ### */
  7719. static int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate) {
  7720. CYTHON_UNUSED_VAR(__pyx_mstate);
  7721. /* Cached unbound methods */
  7722. __pyx_mstate->__pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type;
  7723. __pyx_mstate->__pyx_umethod_PyDict_Type_items.method_name = &__pyx_mstate->__pyx_n_u_items;
  7724. __pyx_mstate->__pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type;
  7725. __pyx_mstate->__pyx_umethod_PyDict_Type_pop.method_name = &__pyx_mstate->__pyx_n_u_pop;
  7726. __pyx_mstate->__pyx_umethod_PyDict_Type_values.type = (PyObject*)&PyDict_Type;
  7727. __pyx_mstate->__pyx_umethod_PyDict_Type_values.method_name = &__pyx_mstate->__pyx_n_u_values;
  7728. return 0;
  7729. }
  7730. /* #### Code section: cached_constants ### */
  7731. static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) {
  7732. __Pyx_RefNannyDeclarations
  7733. CYTHON_UNUSED_VAR(__pyx_mstate);
  7734. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  7735. __Pyx_RefNannyFinishContext();
  7736. return 0;
  7737. }
  7738. /* #### Code section: init_constants ### */
  7739. static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) {
  7740. CYTHON_UNUSED_VAR(__pyx_mstate);
  7741. {
  7742. const struct { const unsigned int length: 11; } index[] = {{1},{28},{1688},{1},{30},{7},{6},{22},{2},{9},{42},{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},{232},{2}};
  7743. #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (1471 bytes) */
  7744. const char* const cstring = "BZh91AY&SY\024\020\0210\000\001F\177\377\357\337\356\002~\377\377\367\277\247\377\312\377\377\377\360@@@@@@@@@\000@@@\000@\000P\005>\251\255\275\267\275W\275\356\227f\341\032\361\341\251\242\023\305S\330\025=\221'\352\023\324\374\244\375\0056\241\344M4bx\223M\032\001\240h\031<j\214jd\362z\240\310\223C OBh\232G\251\355P\36544\r\001\220\3204\000\000\000\000\000\031\006\232\020A!\246\231\032G\351\023\031OP4\320\003G\250\032h\000\000\000\000\000\003\024\204\217!\224\320\364\324\000\000\000\000\000\003@d\000\000\001\204\000I!\004\31120\325?MSjy'\251\247\251\247\250a\251\240\321\240\000\000\032\000\000\003\3244i:\354\214\006\327\323\357\366\314~ >\031\277\241\272\014VIg\021\313g\374\304h5\262\312\0203\340p\354\236\2019\373\006\023\335\373|\316\246B\205\324\245\007\034\374\313\343\374>\360\224\325\r\240\nD1\333C\236\237\013\243\236_\253Q\235\001\303\235\273t\250\020\206\004\255\224\274\320\352<C\330\345\217d\220\"\244CF\376!\273\201\031o\2638Y\226F3\005,\202\231\222\230\030#\241\327\302BCM,\212vA\t\004\344\310Xh\263L\2032S\023\341\356uoR8\366~\335\021\222\351\270p\247N\035\023X\275k\203,J\204\372f\313\003]2(\014\200U\262\226`}P\212td\257`\303,N{\302MM\206\033m\313\233\307q5\201\nm\374B\326\365\3534P\306\233\026\367E\264lBM\000\005\242\014\301\256\301\302/6\243\013W\212\341\354l\367\264\310p\342\035\223|N\034\0165\361\354\nAH\224 h\214b1\357Y\310\214\367P\271\003\357\325|\257\026\260\010\010\225U\001\325\270\341\234\316BA\001\214\323'\010\003\332w\354?T\021\250\t\252\021\337\216\004\001\362\200)&\332b\014\301\006q]\020\007\305\233\006\341B\276\024\260`a\364\353\331\305\222x\262pq\273\310n\\3\200A\237\006\207\344N\240\272l\321\243\320\334\257s\244\222>\0057\206d\321V\000\031> '\200JQN\345\035U\004\340Y\264c\022\350bM\260\302\242\037\223\201\006\226\300\303\265\267M\031\006=\204\014X\2526\312u\301F\223\021\243wcF1\307u\034\020\330\032\212u\261`=\221\006\210^\307\022\262hY\301\301f\376\217v\006\027\354\262\3004\3259\271\371\366,\240U\300\274\027p\367\315:\014\306\344\223\212D6""Oh\246\"=Q\320\345Xk5\271_\301\342\334\265\021\313\\\246-7\033\024\216\341\202\022\203\264\274(\003l\2319LA$(\024\020D\214\366\321F\325\344d \013\271\325\010\021)\030\342\240\016e\322\016\310\367\214\375\203\003\034\365\024\364\177\014\203\"(\236m\n\344\"n\003LAB\276\262\021\266\3307&\231\215\314\306Yi\267z\310V(Dz(\345\264\357\022\320\270\352\233~\303\324h\276;\013\333\375\313\251*\035\200\230\000\211\006\303\326\300\204P\237T\267<+\222T:Jb\266\332\364\251\337:\214$'GO_\207\255\273\262\336,Ph\014,\352\027Qo\220/$D$\355\n\n\275\221\200:\210\360\200\023=\216nd\022\215\376\210V\322Z\366\204\031\035\035\324\225p\247t\312\220\302\252BWx\261\r+\022\300P\227`*\202\241:\206 \010\224,\2224Ud`$Vi\313\017\261\240\362\216Y\n\002\220n\245\344\312\326l.\022\356\255h0M\340\343Zw\030O\035\341`\004\211\250\002\222\001\217V\347\311p\331$\220D$tl\177\213\241\216\303\206&\247\004.F!\324BKJ\211\304m\307\006\216 inV\275\327\314Fa\217i\271\365\035%H\r\301\250\233\307\260\360\203\014J\246J\324\210\000\225\003bY\034\3400\315HE\001\201n\265\341\024n\360\356s_$\305)\232aJ\323Z\031\032\334\027\213\367\201\220.\026\351\267S\246\315\014\215$\024!\000\221\222y4\343\342\215\242$\006\201\021r\363\334\212\365Z\214\264\302\242dNV!@S\244\022B\014\321\242\221\222\257c\031\026\310\321\022L\344V\352\354lY\222\226\267@\327\220?[y\264TU`%.j\330\024\306\210\3146W\"U\213\210\331\366\240\303\003\n\315\214\010LK5\226\014\372+L*G\202\234\305(G\322C%\006\030XL*y\222\014\301\030\013\252\025V\243l\222\212\010\007H\007mR\344\305@R\244N\"\252a\243\026F\315\023\020q~\n\0225\312\210\nH\240\030\347L\025\363g\327;J\006Y\250\330\3161\250\032\260\264j\230aXe\321\\\313\201\3632\020\212e\002\2012\301\254\205vp-\026\262f\207\203\214W\324\332#\245X?\306\022T\214A\350\302\246\321m#B\241\227\021v@\244%H\200f\312\334\023\210\3675\353\244\010\224\320 $,\224\026\312\030b\241\006\233\005\230\310^\033\356\303\"\032\r\032\220g\220Lc\362/\364nlvr\037T\261\334cP\2476\027\206k\021~k\214\374C\224@P\027W^\014\275\033\374\002\331mU\207<T_""\307\325zYu\263\007\357\346t@P\024\357ig\030U`*]\256*+\311\331\241\334\0345\274\3361{%WO\224wD\200\207z(\3562\244kT\325C\001A*S\014\251\242\035T\177\305\334\221N\024$\005\004\004L\000";
  7745. PyObject *data = __Pyx_DecompressString(cstring, 1471, 2);
  7746. if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error)
  7747. const char* const bytes = __Pyx_PyBytes_AsString(data);
  7748. #if !CYTHON_ASSUME_SAFE_MACROS
  7749. if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) }
  7750. #endif
  7751. #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (1342 bytes) */
  7752. const char* const cstring = "x\332}UOo\3336\024o\320d3\262\244]\320\3658\200i7\314\356\\\325r\342\2445\266\016N\323\016\005Z\257\316\322v@\0200\264D;\334$R\021\251$\336\251G\035u\3241G\037{\314\261\037\241G\037\363\021\372\021\366(*\222\275\006%`\232\"\371~\357\275\337\373C\353\005\353?\030\010\256v\205\360\344\003'j\036Ef\266\202\321\016UQ\310\321QD\334\220(\346\240-\372/\243!\222\201\3078\225\210\004A(N\231\017g|\210\324!E\214\007\221BN\324/.Kkq\021\301\350\204C\331\316Vz8QxLe\033u\220\244G\021\345\016Eb\200\356\361{\371I\035Q\342\034\232\017\324\247\032\236\314\\\035\210(,\320\364hn#\025\005\036\005}\227[>9\3054\014Ex\245\242\201'\210\222(\244AH%\345\205\013 \305\374\310G\001\r}&%\353{tF\221K\217\0318,8\032\204\3027v\002\244\026\235\366;w\244\264\206x\036.\231\254\366\201\357Z\033=\037\240\3350\242\250\352\322\001\211<U\003\2034\351\324E\307\304\2134\311!Ed\306\202\022\305\004\302\322(\317\210'i]\2331\312D(\203e\250Y\003\307<Z\n\315@\031\202\305\324=\343C\266\237G\356\351)\361\201\330v{\261\020}\374\370q\356\037V\242\364\252\212\366\212+\226e\301\274\207\252\255F\275\325\250\325Q\325n4\352\360\313\226\255b\331ld\347h\277\376\271\350f\353R\2649#\272\331\202\225\021\335\320\2423\222\373u\264g\327\355}T+\266\367\366\300\n\253QGz\326 \233-\375\245g\203\236}>\262\255\215\231\221\235\315^\005\225\005\216V\224#]\342>\332\264ZS\270k-k\335\236F\254\243\207M\253\361pmjL)\331\000\351)%\033\231\222}\303\372.\244W\221\031\227\365wH xw\030D\207\301\256\340&\232\201`\\\311;HFL\021\310^\250\225\020ER\027\247\201\202|\333\035\005\024\035\034\014=688@\"R\006\360>b\026\244\023\343Y:\017X(U\256\254TN\372\342\230\232`\225\227\246R\222\016}\250&\024F\\\232\n\3113\000)\221\tU5\375\350g\004\254\327\0364\221\211.|\033\372-Ko\326\320\257&_\320\3035\013H\202\270\326\362l4=i\252\225@\356\317\226\026\223\231\213u\310i\217\201mP\2349ayW\311=\272l+\372R\201\006\227\313N\242\261\017\016L\242\003M\000L\375@\215\3529\031P\233\334\354d\030\326\342\027m\312\013\2644\352\013\235\356\363b\255z\224\017\325!\322\371\"\302\274J/7""\327\013r\010\223t\212\2337\272\205<\325-\260\215\230\366\245l\211\340\217+ \344\\(hy\nL\320\321\344\221\337\207\256QXW\266\257\342\215\260\314\353`P\254N\366\004t\205z&\"\356\226\252\270(\363o\352\231\020\274|\002\200\274\276NN\220\313R\024\030\313\265\242\023h^\231=CvL9\nHH|\252\262\307D\213\376vE\357\0012tP[\215V\315eR\353\245\\\317W\333=t\200\250\354\334-)A~$\277D\306\025\276>\371\343\345\253\347/\236n?\211\232\275(\333\311\246\227\235\277p\267\333\351vI\027\343W\243S\370m3G\341.=U;\320\350\211\215\261N\020<\223%D\216\270\303\204\345\210\020*R'l\277o;\216\355h\3170\343X\205\304\241}\342\374\343xB\322\314\250l\232!\302\330z\005C\256k\273\324S\0047\315\337\232\253\214\337\377\247(\2331\036D\334\301\230A\334\206\230I\\X\305$'\234)\352K\317#Ra\206\261O\300:\230\325a\316fI*l\0137\362(\306p\203C\030a\006\026\202\240\021\330A3X\013D\200\265\215\2369\013)\224\t\204\306\305XR\225\013\300*\177\036\363B63\326\377\ng\265\000\364\200\257\034\017\241\367\330\312\306M\214\025\005\343\260:\014\305I\366\224\232\367\364\335\334\247\257\256Uk\237\254k\013\313q'~\233l%N\372]\372\372l\365b\276\022/\304\257\223\325d-\031\244[)\231TV>\256\374p\3269{;~2\036\235\317M*\337\304\233\311O\351\312\305\322\255\244\231\364\222a\332K\207g\273\343\333cr1\277\370q\361{\370&\357\346.\352\367?\275\230\273\266p#\356\305$>I\372\351\365t=\215\316~\037\257g0\363_\277\223\361j\374K\"\323\273ZbR\271\021\377\235\316\245+\372D\305\366\244r3>\322\326\\\217\355\2703\231\277\001(\307\311Nr4\231_\216w\023\270V\211\001e\241\260\357\315\330\036o\277\277\376\276}\336;w?\254\032;\357&\275\311\322\3158Ln%\235\311\267+\223\245\025\220\\\272\255w\2273\r\311\002\254+\313\361Nvg+!Z\256\031\377\231\314i\377l\275\223\234\244$=9s\307?\216O\337\253\363\366\207\336\264\237\377\001C\361TL";
  7753. PyObject *data = __Pyx_DecompressString(cstring, 1342, 1);
  7754. if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error)
  7755. const char* const bytes = __Pyx_PyBytes_AsString(data);
  7756. #if !CYTHON_ASSUME_SAFE_MACROS
  7757. if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) }
  7758. #endif
  7759. #else /* compression: none (2620 bytes) */
  7760. 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. If ``curves`` is empty, returns an empty list.\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 ValueError: if ``max_errors`` does not match the number of curves.\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 505)disableenablefontTools.cu2qu.errorsgcisenabledmax_errors must match the number of curvesApproxNotFoundErrorCOMPILEDCu2QuErrorErrorMAX_NNANNaN__Pyx_PyDict_NextRefaa1__all__all_quadraticasyncio.coroutinesbb1cc1cline_i""n_tracebackclosecurvecurve_to_quadraticcurvescurves_to_quadraticdd1delta_2delta_3dterrorsfontTools.cu2qu.cu2qu__func__iimag_is_coroutineisnanitemsllast_i__main__mathmax_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,-\360L\001\000\005\016\210Q\210a\210w\220b\230\003\2304\230u\240G\2504\250y\270\001\330\004\007\200s\210!\210<\220s\230#\230Q\230a\330\010\016\210j\230\001\230\021\330\004\007\200t\2101\330\010\017\210q\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";
  7761. PyObject *data = NULL;
  7762. CYTHON_UNUSED_VAR(__Pyx_DecompressString);
  7763. #endif
  7764. PyObject **stringtab = __pyx_mstate->__pyx_string_tab;
  7765. Py_ssize_t pos = 0;
  7766. for (int i = 0; i < 78; i++) {
  7767. Py_ssize_t bytes_length = index[i].length;
  7768. PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL);
  7769. if (likely(string) && i >= 11) PyUnicode_InternInPlace(&string);
  7770. if (unlikely(!string)) {
  7771. Py_XDECREF(data);
  7772. __PYX_ERR(0, 1, __pyx_L1_error)
  7773. }
  7774. stringtab[i] = string;
  7775. pos += bytes_length;
  7776. }
  7777. for (int i = 78; i < 81; i++) {
  7778. Py_ssize_t bytes_length = index[i].length;
  7779. PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length);
  7780. stringtab[i] = string;
  7781. pos += bytes_length;
  7782. if (unlikely(!string)) {
  7783. Py_XDECREF(data);
  7784. __PYX_ERR(0, 1, __pyx_L1_error)
  7785. }
  7786. }
  7787. Py_XDECREF(data);
  7788. for (Py_ssize_t i = 0; i < 81; i++) {
  7789. if (unlikely(PyObject_Hash(stringtab[i]) == -1)) {
  7790. __PYX_ERR(0, 1, __pyx_L1_error)
  7791. }
  7792. }
  7793. #if CYTHON_IMMORTAL_CONSTANTS
  7794. {
  7795. PyObject **table = stringtab + 78;
  7796. for (Py_ssize_t i=0; i<3; ++i) {
  7797. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  7798. #if PY_VERSION_HEX < 0x030E0000
  7799. if (_Py_IsOwnedByCurrentThread(table[i]) && Py_REFCNT(table[i]) == 1)
  7800. #else
  7801. if (PyUnstable_Object_IsUniquelyReferenced(table[i]))
  7802. #endif
  7803. {
  7804. Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL);
  7805. }
  7806. #else
  7807. Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
  7808. #endif
  7809. }
  7810. }
  7811. #endif
  7812. }
  7813. {
  7814. PyObject **numbertab = __pyx_mstate->__pyx_number_tab + 0;
  7815. int8_t const cint_constants_1[] = {1,2,3,4,6,100};
  7816. for (int i = 0; i < 6; i++) {
  7817. numbertab[i] = PyLong_FromLong(cint_constants_1[i - 0]);
  7818. if (unlikely(!numbertab[i])) __PYX_ERR(0, 1, __pyx_L1_error)
  7819. }
  7820. }
  7821. #if CYTHON_IMMORTAL_CONSTANTS
  7822. {
  7823. PyObject **table = __pyx_mstate->__pyx_number_tab;
  7824. for (Py_ssize_t i=0; i<6; ++i) {
  7825. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  7826. #if PY_VERSION_HEX < 0x030E0000
  7827. if (_Py_IsOwnedByCurrentThread(table[i]) && Py_REFCNT(table[i]) == 1)
  7828. #else
  7829. if (PyUnstable_Object_IsUniquelyReferenced(table[i]))
  7830. #endif
  7831. {
  7832. Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL);
  7833. }
  7834. #else
  7835. Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
  7836. #endif
  7837. }
  7838. }
  7839. #endif
  7840. return 0;
  7841. __pyx_L1_error:;
  7842. return -1;
  7843. }
  7844. /* #### Code section: init_codeobjects ### */
  7845. typedef struct {
  7846. unsigned int argcount : 3;
  7847. unsigned int num_posonly_args : 1;
  7848. unsigned int num_kwonly_args : 1;
  7849. unsigned int nlocals : 5;
  7850. unsigned int flags : 10;
  7851. unsigned int first_line : 9;
  7852. } __Pyx_PyCode_New_function_description;
  7853. /* NewCodeObj.proto */
  7854. static PyObject* __Pyx_PyCode_New(
  7855. const __Pyx_PyCode_New_function_description descr,
  7856. PyObject * const *varnames,
  7857. PyObject *filename,
  7858. PyObject *funcname,
  7859. PyObject *line_table,
  7860. PyObject *tuple_dedup_map
  7861. );
  7862. static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) {
  7863. PyObject* tuple_dedup_map = PyDict_New();
  7864. if (unlikely(!tuple_dedup_map)) return -1;
  7865. {
  7866. const __Pyx_PyCode_New_function_description descr = {5, 0, 0, 19, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 150};
  7867. 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};
  7868. __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;
  7869. }
  7870. {
  7871. const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 7, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 468};
  7872. 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};
  7873. __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;
  7874. }
  7875. {
  7876. const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 13, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 505};
  7877. 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};
  7878. __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_L_Qawb_4uG4y_s_s_Qa_j_t1_q_1A_a, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[2])) goto bad;
  7879. }
  7880. Py_DECREF(tuple_dedup_map);
  7881. return 0;
  7882. bad:
  7883. Py_DECREF(tuple_dedup_map);
  7884. return -1;
  7885. }
  7886. /* #### Code section: init_globals ### */
  7887. static int __Pyx_InitGlobals(void) {
  7888. /* PythonCompatibility.init */
  7889. if (likely(__Pyx_init_co_variables() == 0)); else
  7890. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  7891. /* CommonTypesMetaclass.init */
  7892. if (likely(__pyx_CommonTypesMetaclass_init(__pyx_m) == 0)); else
  7893. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  7894. /* CachedMethodType.init */
  7895. #if CYTHON_COMPILING_IN_LIMITED_API
  7896. {
  7897. PyObject *typesModule=NULL;
  7898. typesModule = PyImport_ImportModule("types");
  7899. if (typesModule) {
  7900. __pyx_mstate_global->__Pyx_CachedMethodType = PyObject_GetAttrString(typesModule, "MethodType");
  7901. Py_DECREF(typesModule);
  7902. }
  7903. } // error handling follows
  7904. #endif
  7905. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  7906. /* CythonFunctionShared.init */
  7907. if (likely(__pyx_CyFunction_init(__pyx_m) == 0)); else
  7908. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  7909. /* Generator.init */
  7910. if (likely(__pyx_Generator_init(__pyx_m) == 0)); else
  7911. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  7912. return 0;
  7913. __pyx_L1_error:;
  7914. return -1;
  7915. }
  7916. /* #### Code section: cleanup_globals ### */
  7917. /* #### Code section: cleanup_module ### */
  7918. /* #### Code section: main_method ### */
  7919. /* #### Code section: utility_code_pragmas ### */
  7920. #ifdef _MSC_VER
  7921. #pragma warning( push )
  7922. /* Warning 4127: conditional expression is constant
  7923. * Cython uses constant conditional expressions to allow in inline functions to be optimized at
  7924. * compile-time, so this warning is not useful
  7925. */
  7926. #pragma warning( disable : 4127 )
  7927. #endif
  7928. /* #### Code section: utility_code_def ### */
  7929. /* --- Runtime support code --- */
  7930. /* Refnanny */
  7931. #if CYTHON_REFNANNY
  7932. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  7933. PyObject *m = NULL, *p = NULL;
  7934. void *r = NULL;
  7935. m = PyImport_ImportModule(modname);
  7936. if (!m) goto end;
  7937. p = PyObject_GetAttrString(m, "RefNannyAPI");
  7938. if (!p) goto end;
  7939. r = PyLong_AsVoidPtr(p);
  7940. end:
  7941. Py_XDECREF(p);
  7942. Py_XDECREF(m);
  7943. return (__Pyx_RefNannyAPIStruct *)r;
  7944. }
  7945. #endif
  7946. /* PyObjectCall (used by PyObjectFastCall) */
  7947. #if CYTHON_COMPILING_IN_CPYTHON
  7948. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  7949. PyObject *result;
  7950. ternaryfunc call = Py_TYPE(func)->tp_call;
  7951. if (unlikely(!call))
  7952. return PyObject_Call(func, arg, kw);
  7953. if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
  7954. return NULL;
  7955. result = (*call)(func, arg, kw);
  7956. Py_LeaveRecursiveCall();
  7957. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  7958. PyErr_SetString(
  7959. PyExc_SystemError,
  7960. "NULL result without error in PyObject_Call");
  7961. }
  7962. return result;
  7963. }
  7964. #endif
  7965. /* PyObjectCallMethO (used by PyObjectFastCall) */
  7966. #if CYTHON_COMPILING_IN_CPYTHON
  7967. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  7968. PyObject *self, *result;
  7969. PyCFunction cfunc;
  7970. cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func);
  7971. self = __Pyx_CyOrPyCFunction_GET_SELF(func);
  7972. if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
  7973. return NULL;
  7974. result = cfunc(self, arg);
  7975. Py_LeaveRecursiveCall();
  7976. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  7977. PyErr_SetString(
  7978. PyExc_SystemError,
  7979. "NULL result without error in PyObject_Call");
  7980. }
  7981. return result;
  7982. }
  7983. #endif
  7984. /* PyObjectFastCall */
  7985. #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API
  7986. static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs) {
  7987. PyObject *argstuple;
  7988. PyObject *result = 0;
  7989. size_t i;
  7990. argstuple = PyTuple_New((Py_ssize_t)nargs);
  7991. if (unlikely(!argstuple)) return NULL;
  7992. for (i = 0; i < nargs; i++) {
  7993. Py_INCREF(args[i]);
  7994. if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) != (0)) goto bad;
  7995. }
  7996. result = __Pyx_PyObject_Call(func, argstuple, kwargs);
  7997. bad:
  7998. Py_DECREF(argstuple);
  7999. return result;
  8000. }
  8001. #endif
  8002. #if CYTHON_VECTORCALL && !CYTHON_COMPILING_IN_LIMITED_API
  8003. #if PY_VERSION_HEX < 0x03090000
  8004. #define __Pyx_PyVectorcall_Function(callable) _PyVectorcall_Function(callable)
  8005. #elif CYTHON_COMPILING_IN_CPYTHON
  8006. static CYTHON_INLINE vectorcallfunc __Pyx_PyVectorcall_Function(PyObject *callable) {
  8007. PyTypeObject *tp = Py_TYPE(callable);
  8008. #if defined(__Pyx_CyFunction_USED)
  8009. if (__Pyx_CyFunction_CheckExact(callable)) {
  8010. return __Pyx_CyFunction_func_vectorcall(callable);
  8011. }
  8012. #endif
  8013. if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) {
  8014. return NULL;
  8015. }
  8016. assert(PyCallable_Check(callable));
  8017. Py_ssize_t offset = tp->tp_vectorcall_offset;
  8018. assert(offset > 0);
  8019. vectorcallfunc ptr;
  8020. memcpy(&ptr, (char *) callable + offset, sizeof(ptr));
  8021. return ptr;
  8022. }
  8023. #else
  8024. #define __Pyx_PyVectorcall_Function(callable) PyVectorcall_Function(callable)
  8025. #endif
  8026. #endif
  8027. static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject *const *args, size_t _nargs, PyObject *kwargs) {
  8028. Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs);
  8029. #if CYTHON_COMPILING_IN_CPYTHON
  8030. if (nargs == 0 && kwargs == NULL) {
  8031. if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS))
  8032. return __Pyx_PyObject_CallMethO(func, NULL);
  8033. }
  8034. else if (nargs == 1 && kwargs == NULL) {
  8035. if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O))
  8036. return __Pyx_PyObject_CallMethO(func, args[0]);
  8037. }
  8038. #endif
  8039. if (kwargs == NULL) {
  8040. #if CYTHON_VECTORCALL
  8041. #if CYTHON_COMPILING_IN_LIMITED_API
  8042. return PyObject_Vectorcall(func, args, _nargs, NULL);
  8043. #else
  8044. vectorcallfunc f = __Pyx_PyVectorcall_Function(func);
  8045. if (f) {
  8046. return f(func, args, _nargs, NULL);
  8047. }
  8048. #endif
  8049. #endif
  8050. }
  8051. if (nargs == 0) {
  8052. return __Pyx_PyObject_Call(func, __pyx_mstate_global->__pyx_empty_tuple, kwargs);
  8053. }
  8054. #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API
  8055. return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs);
  8056. #else
  8057. return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs);
  8058. #endif
  8059. }
  8060. /* PyLongCompare */
  8061. static CYTHON_INLINE int __Pyx_PyLong_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace) {
  8062. CYTHON_MAYBE_UNUSED_VAR(intval);
  8063. CYTHON_UNUSED_VAR(inplace);
  8064. if (op1 == op2) {
  8065. return 1;
  8066. }
  8067. #if CYTHON_USE_PYLONG_INTERNALS
  8068. if (likely(PyLong_CheckExact(op1))) {
  8069. int unequal;
  8070. unsigned long uintval;
  8071. Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
  8072. const digit* digits = __Pyx_PyLong_Digits(op1);
  8073. if (intval == 0) {
  8074. return (__Pyx_PyLong_IsZero(op1) == 1);
  8075. } else if (intval < 0) {
  8076. if (__Pyx_PyLong_IsNonNeg(op1))
  8077. return 0;
  8078. intval = -intval;
  8079. } else {
  8080. if (__Pyx_PyLong_IsNeg(op1))
  8081. return 0;
  8082. }
  8083. uintval = (unsigned long) intval;
  8084. #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
  8085. if (uintval >> (PyLong_SHIFT * 4)) {
  8086. unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
  8087. | (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));
  8088. } else
  8089. #endif
  8090. #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
  8091. if (uintval >> (PyLong_SHIFT * 3)) {
  8092. unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
  8093. | (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));
  8094. } else
  8095. #endif
  8096. #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
  8097. if (uintval >> (PyLong_SHIFT * 2)) {
  8098. unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
  8099. | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
  8100. } else
  8101. #endif
  8102. #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
  8103. if (uintval >> (PyLong_SHIFT * 1)) {
  8104. unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
  8105. | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
  8106. } else
  8107. #endif
  8108. unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
  8109. return (unequal == 0);
  8110. }
  8111. #endif
  8112. if (PyFloat_CheckExact(op1)) {
  8113. const long b = intval;
  8114. double a = __Pyx_PyFloat_AS_DOUBLE(op1);
  8115. return ((double)a == (double)b);
  8116. }
  8117. return __Pyx_PyObject_IsTrueAndDecref(
  8118. PyObject_RichCompare(op1, op2, Py_EQ));
  8119. }
  8120. /* RaiseTooManyValuesToUnpack */
  8121. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
  8122. PyErr_Format(PyExc_ValueError,
  8123. "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
  8124. }
  8125. /* RaiseNeedMoreValuesToUnpack */
  8126. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
  8127. PyErr_Format(PyExc_ValueError,
  8128. "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
  8129. index, (index == 1) ? "" : "s");
  8130. }
  8131. /* PyErrFetchRestore (used by IterFinish) */
  8132. #if CYTHON_FAST_THREAD_STATE
  8133. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  8134. #if PY_VERSION_HEX >= 0x030C00A6
  8135. PyObject *tmp_value;
  8136. assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value)));
  8137. if (value) {
  8138. #if CYTHON_COMPILING_IN_CPYTHON
  8139. if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb))
  8140. #endif
  8141. PyException_SetTraceback(value, tb);
  8142. }
  8143. tmp_value = tstate->current_exception;
  8144. tstate->current_exception = value;
  8145. Py_XDECREF(tmp_value);
  8146. Py_XDECREF(type);
  8147. Py_XDECREF(tb);
  8148. #else
  8149. PyObject *tmp_type, *tmp_value, *tmp_tb;
  8150. tmp_type = tstate->curexc_type;
  8151. tmp_value = tstate->curexc_value;
  8152. tmp_tb = tstate->curexc_traceback;
  8153. tstate->curexc_type = type;
  8154. tstate->curexc_value = value;
  8155. tstate->curexc_traceback = tb;
  8156. Py_XDECREF(tmp_type);
  8157. Py_XDECREF(tmp_value);
  8158. Py_XDECREF(tmp_tb);
  8159. #endif
  8160. }
  8161. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  8162. #if PY_VERSION_HEX >= 0x030C00A6
  8163. PyObject* exc_value;
  8164. exc_value = tstate->current_exception;
  8165. tstate->current_exception = 0;
  8166. *value = exc_value;
  8167. *type = NULL;
  8168. *tb = NULL;
  8169. if (exc_value) {
  8170. *type = (PyObject*) Py_TYPE(exc_value);
  8171. Py_INCREF(*type);
  8172. #if CYTHON_COMPILING_IN_CPYTHON
  8173. *tb = ((PyBaseExceptionObject*) exc_value)->traceback;
  8174. Py_XINCREF(*tb);
  8175. #else
  8176. *tb = PyException_GetTraceback(exc_value);
  8177. #endif
  8178. }
  8179. #else
  8180. *type = tstate->curexc_type;
  8181. *value = tstate->curexc_value;
  8182. *tb = tstate->curexc_traceback;
  8183. tstate->curexc_type = 0;
  8184. tstate->curexc_value = 0;
  8185. tstate->curexc_traceback = 0;
  8186. #endif
  8187. }
  8188. #endif
  8189. /* IterFinish */
  8190. static CYTHON_INLINE int __Pyx_IterFinish(void) {
  8191. PyObject* exc_type;
  8192. __Pyx_PyThreadState_declare
  8193. __Pyx_PyThreadState_assign
  8194. exc_type = __Pyx_PyErr_CurrentExceptionType();
  8195. if (unlikely(exc_type)) {
  8196. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
  8197. return -1;
  8198. __Pyx_PyErr_Clear();
  8199. return 0;
  8200. }
  8201. return 0;
  8202. }
  8203. /* UnpackItemEndCheck */
  8204. static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
  8205. if (unlikely(retval)) {
  8206. Py_DECREF(retval);
  8207. __Pyx_RaiseTooManyValuesError(expected);
  8208. return -1;
  8209. }
  8210. return __Pyx_IterFinish();
  8211. }
  8212. /* GetItemInt */
  8213. static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
  8214. PyObject *r;
  8215. if (unlikely(!j)) return NULL;
  8216. r = PyObject_GetItem(o, j);
  8217. Py_DECREF(j);
  8218. return r;
  8219. }
  8220. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  8221. int wraparound, int boundscheck, int unsafe_shared) {
  8222. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  8223. #if CYTHON_ASSUME_SAFE_SIZE
  8224. Py_ssize_t wrapped_i = i;
  8225. if (wraparound & unlikely(i < 0)) {
  8226. wrapped_i += PyList_GET_SIZE(o);
  8227. }
  8228. if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS)) {
  8229. return __Pyx_PyList_GetItemRefFast(o, wrapped_i, unsafe_shared);
  8230. } else
  8231. if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
  8232. return __Pyx_NewRef(PyList_GET_ITEM(o, wrapped_i));
  8233. }
  8234. return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
  8235. #else
  8236. (void)wraparound;
  8237. (void)boundscheck;
  8238. return PySequence_GetItem(o, i);
  8239. #endif
  8240. }
  8241. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  8242. int wraparound, int boundscheck, int unsafe_shared) {
  8243. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  8244. #if CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8245. Py_ssize_t wrapped_i = i;
  8246. if (wraparound & unlikely(i < 0)) {
  8247. wrapped_i += PyTuple_GET_SIZE(o);
  8248. }
  8249. if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
  8250. return __Pyx_NewRef(PyTuple_GET_ITEM(o, wrapped_i));
  8251. }
  8252. return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
  8253. #else
  8254. (void)wraparound;
  8255. (void)boundscheck;
  8256. return PySequence_GetItem(o, i);
  8257. #endif
  8258. }
  8259. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
  8260. int wraparound, int boundscheck, int unsafe_shared) {
  8261. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  8262. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  8263. if (is_list || PyList_CheckExact(o)) {
  8264. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
  8265. if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)) {
  8266. return __Pyx_PyList_GetItemRefFast(o, n, unsafe_shared);
  8267. } else if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
  8268. return __Pyx_NewRef(PyList_GET_ITEM(o, n));
  8269. }
  8270. } else
  8271. #if !CYTHON_AVOID_BORROWED_REFS
  8272. if (PyTuple_CheckExact(o)) {
  8273. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
  8274. if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
  8275. return __Pyx_NewRef(PyTuple_GET_ITEM(o, n));
  8276. }
  8277. } else
  8278. #endif
  8279. #endif
  8280. #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
  8281. {
  8282. PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
  8283. PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
  8284. if (!is_list && mm && mm->mp_subscript) {
  8285. PyObject *r, *key = PyLong_FromSsize_t(i);
  8286. if (unlikely(!key)) return NULL;
  8287. r = mm->mp_subscript(o, key);
  8288. Py_DECREF(key);
  8289. return r;
  8290. }
  8291. if (is_list || likely(sm && sm->sq_item)) {
  8292. if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
  8293. Py_ssize_t l = sm->sq_length(o);
  8294. if (likely(l >= 0)) {
  8295. i += l;
  8296. } else {
  8297. if (!PyErr_ExceptionMatches(PyExc_OverflowError))
  8298. return NULL;
  8299. PyErr_Clear();
  8300. }
  8301. }
  8302. return sm->sq_item(o, i);
  8303. }
  8304. }
  8305. #else
  8306. if (is_list || !PyMapping_Check(o)) {
  8307. return PySequence_GetItem(o, i);
  8308. }
  8309. #endif
  8310. (void)wraparound;
  8311. (void)boundscheck;
  8312. return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
  8313. }
  8314. /* PyErrExceptionMatches (used by PyObjectGetAttrStrNoError) */
  8315. #if CYTHON_FAST_THREAD_STATE
  8316. static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  8317. Py_ssize_t i, n;
  8318. n = PyTuple_GET_SIZE(tuple);
  8319. for (i=0; i<n; i++) {
  8320. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  8321. }
  8322. for (i=0; i<n; i++) {
  8323. if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
  8324. }
  8325. return 0;
  8326. }
  8327. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
  8328. int result;
  8329. PyObject *exc_type;
  8330. #if PY_VERSION_HEX >= 0x030C00A6
  8331. PyObject *current_exception = tstate->current_exception;
  8332. if (unlikely(!current_exception)) return 0;
  8333. exc_type = (PyObject*) Py_TYPE(current_exception);
  8334. if (exc_type == err) return 1;
  8335. #else
  8336. exc_type = tstate->curexc_type;
  8337. if (exc_type == err) return 1;
  8338. if (unlikely(!exc_type)) return 0;
  8339. #endif
  8340. #if CYTHON_AVOID_BORROWED_REFS
  8341. Py_INCREF(exc_type);
  8342. #endif
  8343. if (unlikely(PyTuple_Check(err))) {
  8344. result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
  8345. } else {
  8346. result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
  8347. }
  8348. #if CYTHON_AVOID_BORROWED_REFS
  8349. Py_DECREF(exc_type);
  8350. #endif
  8351. return result;
  8352. }
  8353. #endif
  8354. /* PyObjectGetAttrStr (used by PyObjectGetAttrStrNoError) */
  8355. #if CYTHON_USE_TYPE_SLOTS
  8356. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  8357. PyTypeObject* tp = Py_TYPE(obj);
  8358. if (likely(tp->tp_getattro))
  8359. return tp->tp_getattro(obj, attr_name);
  8360. return PyObject_GetAttr(obj, attr_name);
  8361. }
  8362. #endif
  8363. /* PyObjectGetAttrStrNoError (used by GetBuiltinName) */
  8364. #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
  8365. static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
  8366. __Pyx_PyThreadState_declare
  8367. __Pyx_PyThreadState_assign
  8368. if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
  8369. __Pyx_PyErr_Clear();
  8370. }
  8371. #endif
  8372. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
  8373. PyObject *result;
  8374. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  8375. (void) PyObject_GetOptionalAttr(obj, attr_name, &result);
  8376. return result;
  8377. #else
  8378. #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS
  8379. PyTypeObject* tp = Py_TYPE(obj);
  8380. if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
  8381. return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
  8382. }
  8383. #endif
  8384. result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
  8385. if (unlikely(!result)) {
  8386. __Pyx_PyObject_GetAttrStr_ClearAttributeError();
  8387. }
  8388. return result;
  8389. #endif
  8390. }
  8391. /* GetBuiltinName (used by GetModuleGlobalName) */
  8392. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  8393. PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_mstate_global->__pyx_b, name);
  8394. if (unlikely(!result) && !PyErr_Occurred()) {
  8395. PyErr_Format(PyExc_NameError,
  8396. "name '%U' is not defined", name);
  8397. }
  8398. return result;
  8399. }
  8400. /* PyDictVersioning (used by GetModuleGlobalName) */
  8401. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  8402. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
  8403. PyObject *dict = Py_TYPE(obj)->tp_dict;
  8404. return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
  8405. }
  8406. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
  8407. PyObject **dictptr = NULL;
  8408. Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
  8409. if (offset) {
  8410. #if CYTHON_COMPILING_IN_CPYTHON
  8411. dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
  8412. #else
  8413. dictptr = _PyObject_GetDictPtr(obj);
  8414. #endif
  8415. }
  8416. return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
  8417. }
  8418. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
  8419. PyObject *dict = Py_TYPE(obj)->tp_dict;
  8420. if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
  8421. return 0;
  8422. return obj_dict_version == __Pyx_get_object_dict_version(obj);
  8423. }
  8424. #endif
  8425. /* GetModuleGlobalName */
  8426. #if CYTHON_USE_DICT_VERSIONS
  8427. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
  8428. #else
  8429. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
  8430. #endif
  8431. {
  8432. PyObject *result;
  8433. #if CYTHON_COMPILING_IN_LIMITED_API
  8434. if (unlikely(!__pyx_m)) {
  8435. if (!PyErr_Occurred())
  8436. PyErr_SetNone(PyExc_NameError);
  8437. return NULL;
  8438. }
  8439. result = PyObject_GetAttr(__pyx_m, name);
  8440. if (likely(result)) {
  8441. return result;
  8442. }
  8443. PyErr_Clear();
  8444. #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  8445. if (unlikely(__Pyx_PyDict_GetItemRef(__pyx_mstate_global->__pyx_d, name, &result) == -1)) PyErr_Clear();
  8446. __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version)
  8447. if (likely(result)) {
  8448. return result;
  8449. }
  8450. #else
  8451. result = _PyDict_GetItem_KnownHash(__pyx_mstate_global->__pyx_d, name, ((PyASCIIObject *) name)->hash);
  8452. __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version)
  8453. if (likely(result)) {
  8454. return __Pyx_NewRef(result);
  8455. }
  8456. PyErr_Clear();
  8457. #endif
  8458. return __Pyx_GetBuiltinName(name);
  8459. }
  8460. /* TupleAndListFromArray (used by fastcall) */
  8461. #if !CYTHON_COMPILING_IN_CPYTHON && CYTHON_METH_FASTCALL
  8462. static CYTHON_INLINE PyObject *
  8463. __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
  8464. {
  8465. PyObject *res;
  8466. Py_ssize_t i;
  8467. if (n <= 0) {
  8468. return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple);
  8469. }
  8470. res = PyTuple_New(n);
  8471. if (unlikely(res == NULL)) return NULL;
  8472. for (i = 0; i < n; i++) {
  8473. if (unlikely(__Pyx_PyTuple_SET_ITEM(res, i, src[i]) < (0))) {
  8474. Py_DECREF(res);
  8475. return NULL;
  8476. }
  8477. Py_INCREF(src[i]);
  8478. }
  8479. return res;
  8480. }
  8481. #elif CYTHON_COMPILING_IN_CPYTHON
  8482. static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
  8483. PyObject *v;
  8484. Py_ssize_t i;
  8485. for (i = 0; i < length; i++) {
  8486. v = dest[i] = src[i];
  8487. Py_INCREF(v);
  8488. }
  8489. }
  8490. static CYTHON_INLINE PyObject *
  8491. __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
  8492. {
  8493. PyObject *res;
  8494. if (n <= 0) {
  8495. return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple);
  8496. }
  8497. res = PyTuple_New(n);
  8498. if (unlikely(res == NULL)) return NULL;
  8499. __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n);
  8500. return res;
  8501. }
  8502. static CYTHON_INLINE PyObject *
  8503. __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n)
  8504. {
  8505. PyObject *res;
  8506. if (n <= 0) {
  8507. return PyList_New(0);
  8508. }
  8509. res = PyList_New(n);
  8510. if (unlikely(res == NULL)) return NULL;
  8511. __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n);
  8512. return res;
  8513. }
  8514. #endif
  8515. /* BytesEquals (used by UnicodeEquals) */
  8516. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
  8517. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL ||\
  8518. !(CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS)
  8519. return PyObject_RichCompareBool(s1, s2, equals);
  8520. #else
  8521. if (s1 == s2) {
  8522. return (equals == Py_EQ);
  8523. } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
  8524. const char *ps1, *ps2;
  8525. Py_ssize_t length = PyBytes_GET_SIZE(s1);
  8526. if (length != PyBytes_GET_SIZE(s2))
  8527. return (equals == Py_NE);
  8528. ps1 = PyBytes_AS_STRING(s1);
  8529. ps2 = PyBytes_AS_STRING(s2);
  8530. if (ps1[0] != ps2[0]) {
  8531. return (equals == Py_NE);
  8532. } else if (length == 1) {
  8533. return (equals == Py_EQ);
  8534. } else {
  8535. int result;
  8536. #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000)
  8537. Py_hash_t hash1, hash2;
  8538. hash1 = ((PyBytesObject*)s1)->ob_shash;
  8539. hash2 = ((PyBytesObject*)s2)->ob_shash;
  8540. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  8541. return (equals == Py_NE);
  8542. }
  8543. #endif
  8544. result = memcmp(ps1, ps2, (size_t)length);
  8545. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  8546. }
  8547. } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
  8548. return (equals == Py_NE);
  8549. } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
  8550. return (equals == Py_NE);
  8551. } else {
  8552. int result;
  8553. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  8554. if (!py_result)
  8555. return -1;
  8556. result = __Pyx_PyObject_IsTrue(py_result);
  8557. Py_DECREF(py_result);
  8558. return result;
  8559. }
  8560. #endif
  8561. }
  8562. /* UnicodeEquals (used by fastcall) */
  8563. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
  8564. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
  8565. return PyObject_RichCompareBool(s1, s2, equals);
  8566. #else
  8567. int s1_is_unicode, s2_is_unicode;
  8568. if (s1 == s2) {
  8569. goto return_eq;
  8570. }
  8571. s1_is_unicode = PyUnicode_CheckExact(s1);
  8572. s2_is_unicode = PyUnicode_CheckExact(s2);
  8573. if (s1_is_unicode & s2_is_unicode) {
  8574. Py_ssize_t length, length2;
  8575. int kind;
  8576. void *data1, *data2;
  8577. #if !CYTHON_COMPILING_IN_LIMITED_API
  8578. if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
  8579. return -1;
  8580. #endif
  8581. length = __Pyx_PyUnicode_GET_LENGTH(s1);
  8582. #if !CYTHON_ASSUME_SAFE_SIZE
  8583. if (unlikely(length < 0)) return -1;
  8584. #endif
  8585. length2 = __Pyx_PyUnicode_GET_LENGTH(s2);
  8586. #if !CYTHON_ASSUME_SAFE_SIZE
  8587. if (unlikely(length2 < 0)) return -1;
  8588. #endif
  8589. if (length != length2) {
  8590. goto return_ne;
  8591. }
  8592. #if CYTHON_USE_UNICODE_INTERNALS
  8593. {
  8594. Py_hash_t hash1, hash2;
  8595. hash1 = ((PyASCIIObject*)s1)->hash;
  8596. hash2 = ((PyASCIIObject*)s2)->hash;
  8597. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  8598. goto return_ne;
  8599. }
  8600. }
  8601. #endif
  8602. kind = __Pyx_PyUnicode_KIND(s1);
  8603. if (kind != __Pyx_PyUnicode_KIND(s2)) {
  8604. goto return_ne;
  8605. }
  8606. data1 = __Pyx_PyUnicode_DATA(s1);
  8607. data2 = __Pyx_PyUnicode_DATA(s2);
  8608. if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
  8609. goto return_ne;
  8610. } else if (length == 1) {
  8611. goto return_eq;
  8612. } else {
  8613. int result = memcmp(data1, data2, (size_t)(length * kind));
  8614. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  8615. }
  8616. } else if ((s1 == Py_None) & s2_is_unicode) {
  8617. goto return_ne;
  8618. } else if ((s2 == Py_None) & s1_is_unicode) {
  8619. goto return_ne;
  8620. } else {
  8621. int result;
  8622. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  8623. if (!py_result)
  8624. return -1;
  8625. result = __Pyx_PyObject_IsTrue(py_result);
  8626. Py_DECREF(py_result);
  8627. return result;
  8628. }
  8629. return_eq:
  8630. return (equals == Py_EQ);
  8631. return_ne:
  8632. return (equals == Py_NE);
  8633. #endif
  8634. }
  8635. /* fastcall */
  8636. #if CYTHON_METH_FASTCALL
  8637. static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s)
  8638. {
  8639. Py_ssize_t i, n = __Pyx_PyTuple_GET_SIZE(kwnames);
  8640. #if !CYTHON_ASSUME_SAFE_SIZE
  8641. if (unlikely(n == -1)) return NULL;
  8642. #endif
  8643. for (i = 0; i < n; i++)
  8644. {
  8645. PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
  8646. #if !CYTHON_ASSUME_SAFE_MACROS
  8647. if (unlikely(!namei)) return NULL;
  8648. #endif
  8649. if (s == namei) return kwvalues[i];
  8650. }
  8651. for (i = 0; i < n; i++)
  8652. {
  8653. PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
  8654. #if !CYTHON_ASSUME_SAFE_MACROS
  8655. if (unlikely(!namei)) return NULL;
  8656. #endif
  8657. int eq = __Pyx_PyUnicode_Equals(s, namei, Py_EQ);
  8658. if (unlikely(eq != 0)) {
  8659. if (unlikely(eq < 0)) return NULL;
  8660. return kwvalues[i];
  8661. }
  8662. }
  8663. return NULL;
  8664. }
  8665. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
  8666. CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) {
  8667. Py_ssize_t i, nkwargs;
  8668. PyObject *dict;
  8669. #if !CYTHON_ASSUME_SAFE_SIZE
  8670. nkwargs = PyTuple_Size(kwnames);
  8671. if (unlikely(nkwargs < 0)) return NULL;
  8672. #else
  8673. nkwargs = PyTuple_GET_SIZE(kwnames);
  8674. #endif
  8675. dict = PyDict_New();
  8676. if (unlikely(!dict))
  8677. return NULL;
  8678. for (i=0; i<nkwargs; i++) {
  8679. #if !CYTHON_ASSUME_SAFE_MACROS
  8680. PyObject *key = PyTuple_GetItem(kwnames, i);
  8681. if (!key) goto bad;
  8682. #else
  8683. PyObject *key = PyTuple_GET_ITEM(kwnames, i);
  8684. #endif
  8685. if (unlikely(PyDict_SetItem(dict, key, kwvalues[i]) < 0))
  8686. goto bad;
  8687. }
  8688. return dict;
  8689. bad:
  8690. Py_DECREF(dict);
  8691. return NULL;
  8692. }
  8693. #endif
  8694. #endif
  8695. /* PyObjectCallOneArg (used by CallUnboundCMethod0) */
  8696. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  8697. PyObject *args[2] = {NULL, arg};
  8698. return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  8699. }
  8700. /* UnpackUnboundCMethod (used by CallUnboundCMethod0) */
  8701. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000
  8702. static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) {
  8703. PyObject *result;
  8704. PyObject *selfless_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args));
  8705. if (unlikely(!selfless_args)) return NULL;
  8706. result = PyObject_Call(method, selfless_args, kwargs);
  8707. Py_DECREF(selfless_args);
  8708. return result;
  8709. }
  8710. #elif CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03090000
  8711. static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) {
  8712. return _PyObject_Vectorcall
  8713. (method, args ? args+1 : NULL, nargs ? nargs-1 : 0, kwnames);
  8714. }
  8715. #else
  8716. static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) {
  8717. return
  8718. #if PY_VERSION_HEX < 0x03090000
  8719. _PyObject_Vectorcall
  8720. #else
  8721. PyObject_Vectorcall
  8722. #endif
  8723. (method, args ? args+1 : NULL, nargs ? (size_t) nargs-1 : 0, kwnames);
  8724. }
  8725. #endif
  8726. static PyMethodDef __Pyx_UnboundCMethod_Def = {
  8727. "CythonUnboundCMethod",
  8728. __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_SelflessCall),
  8729. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000
  8730. METH_VARARGS | METH_KEYWORDS,
  8731. #else
  8732. METH_FASTCALL | METH_KEYWORDS,
  8733. #endif
  8734. NULL
  8735. };
  8736. static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
  8737. PyObject *method, *result=NULL;
  8738. method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
  8739. if (unlikely(!method))
  8740. return -1;
  8741. result = method;
  8742. #if CYTHON_COMPILING_IN_CPYTHON
  8743. if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
  8744. {
  8745. PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
  8746. target->func = descr->d_method->ml_meth;
  8747. target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
  8748. } else
  8749. #endif
  8750. #if CYTHON_COMPILING_IN_PYPY
  8751. #else
  8752. if (PyCFunction_Check(method))
  8753. #endif
  8754. {
  8755. PyObject *self;
  8756. int self_found;
  8757. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
  8758. self = PyObject_GetAttrString(method, "__self__");
  8759. if (!self) {
  8760. PyErr_Clear();
  8761. }
  8762. #else
  8763. self = PyCFunction_GET_SELF(method);
  8764. #endif
  8765. self_found = (self && self != Py_None);
  8766. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
  8767. Py_XDECREF(self);
  8768. #endif
  8769. if (self_found) {
  8770. PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method);
  8771. if (unlikely(!unbound_method)) return -1;
  8772. Py_DECREF(method);
  8773. result = unbound_method;
  8774. }
  8775. }
  8776. #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  8777. if (unlikely(target->method)) {
  8778. Py_DECREF(result);
  8779. } else
  8780. #endif
  8781. target->method = result;
  8782. return 0;
  8783. }
  8784. /* CallUnboundCMethod0 */
  8785. #if CYTHON_COMPILING_IN_CPYTHON
  8786. static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
  8787. int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc);
  8788. if (likely(was_initialized == 2 && cfunc->func)) {
  8789. if (likely(cfunc->flag == METH_NOARGS))
  8790. return __Pyx_CallCFunction(cfunc, self, NULL);
  8791. if (likely(cfunc->flag == METH_FASTCALL))
  8792. return __Pyx_CallCFunctionFast(cfunc, self, NULL, 0);
  8793. if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
  8794. return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, NULL, 0, NULL);
  8795. if (likely(cfunc->flag == (METH_VARARGS | METH_KEYWORDS)))
  8796. return __Pyx_CallCFunctionWithKeywords(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  8797. if (cfunc->flag == METH_VARARGS)
  8798. return __Pyx_CallCFunction(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple);
  8799. return __Pyx__CallUnboundCMethod0(cfunc, self);
  8800. }
  8801. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  8802. else if (unlikely(was_initialized == 1)) {
  8803. __Pyx_CachedCFunction tmp_cfunc = {
  8804. #ifndef __cplusplus
  8805. 0
  8806. #endif
  8807. };
  8808. tmp_cfunc.type = cfunc->type;
  8809. tmp_cfunc.method_name = cfunc->method_name;
  8810. return __Pyx__CallUnboundCMethod0(&tmp_cfunc, self);
  8811. }
  8812. #endif
  8813. PyObject *result = __Pyx__CallUnboundCMethod0(cfunc, self);
  8814. __Pyx_CachedCFunction_SetFinishedInitializing(cfunc);
  8815. return result;
  8816. }
  8817. #endif
  8818. static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
  8819. PyObject *result;
  8820. if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
  8821. result = __Pyx_PyObject_CallOneArg(cfunc->method, self);
  8822. return result;
  8823. }
  8824. /* py_dict_items (used by OwnedDictNext) */
  8825. static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
  8826. return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_items, d);
  8827. }
  8828. /* py_dict_values (used by OwnedDictNext) */
  8829. static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) {
  8830. return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_values, d);
  8831. }
  8832. /* OwnedDictNext (used by ParseKeywordsImpl) */
  8833. #if CYTHON_AVOID_BORROWED_REFS
  8834. static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue) {
  8835. PyObject *next = NULL;
  8836. if (!*ppos) {
  8837. if (pvalue) {
  8838. PyObject *dictview = pkey ? __Pyx_PyDict_Items(p) : __Pyx_PyDict_Values(p);
  8839. if (unlikely(!dictview)) goto bad;
  8840. *ppos = PyObject_GetIter(dictview);
  8841. Py_DECREF(dictview);
  8842. } else {
  8843. *ppos = PyObject_GetIter(p);
  8844. }
  8845. if (unlikely(!*ppos)) goto bad;
  8846. }
  8847. next = PyIter_Next(*ppos);
  8848. if (!next) {
  8849. if (PyErr_Occurred()) goto bad;
  8850. return 0;
  8851. }
  8852. if (pkey && pvalue) {
  8853. *pkey = __Pyx_PySequence_ITEM(next, 0);
  8854. if (unlikely(*pkey)) goto bad;
  8855. *pvalue = __Pyx_PySequence_ITEM(next, 1);
  8856. if (unlikely(*pvalue)) goto bad;
  8857. Py_DECREF(next);
  8858. } else if (pkey) {
  8859. *pkey = next;
  8860. } else {
  8861. assert(pvalue);
  8862. *pvalue = next;
  8863. }
  8864. return 1;
  8865. bad:
  8866. Py_XDECREF(next);
  8867. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
  8868. PyErr_FormatUnraisable("Exception ignored in __Pyx_PyDict_NextRef");
  8869. #else
  8870. PyErr_WriteUnraisable(__pyx_mstate_global->__pyx_n_u_Pyx_PyDict_NextRef);
  8871. #endif
  8872. if (pkey) *pkey = NULL;
  8873. if (pvalue) *pvalue = NULL;
  8874. return 0;
  8875. }
  8876. #else // !CYTHON_AVOID_BORROWED_REFS
  8877. static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue) {
  8878. int result = PyDict_Next(p, ppos, pkey, pvalue);
  8879. if (likely(result == 1)) {
  8880. if (pkey) Py_INCREF(*pkey);
  8881. if (pvalue) Py_INCREF(*pvalue);
  8882. }
  8883. return result;
  8884. }
  8885. #endif
  8886. /* RaiseDoubleKeywords (used by ParseKeywordsImpl) */
  8887. static void __Pyx_RaiseDoubleKeywordsError(
  8888. const char* func_name,
  8889. PyObject* kw_name)
  8890. {
  8891. PyErr_Format(PyExc_TypeError,
  8892. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  8893. }
  8894. /* CallUnboundCMethod2 */
  8895. #if CYTHON_COMPILING_IN_CPYTHON
  8896. static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
  8897. int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc);
  8898. if (likely(was_initialized == 2 && cfunc->func)) {
  8899. PyObject *args[2] = {arg1, arg2};
  8900. if (cfunc->flag == METH_FASTCALL) {
  8901. return __Pyx_CallCFunctionFast(cfunc, self, args, 2);
  8902. }
  8903. if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
  8904. return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, 2, NULL);
  8905. }
  8906. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  8907. else if (unlikely(was_initialized == 1)) {
  8908. __Pyx_CachedCFunction tmp_cfunc = {
  8909. #ifndef __cplusplus
  8910. 0
  8911. #endif
  8912. };
  8913. tmp_cfunc.type = cfunc->type;
  8914. tmp_cfunc.method_name = cfunc->method_name;
  8915. return __Pyx__CallUnboundCMethod2(&tmp_cfunc, self, arg1, arg2);
  8916. }
  8917. #endif
  8918. PyObject *result = __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
  8919. __Pyx_CachedCFunction_SetFinishedInitializing(cfunc);
  8920. return result;
  8921. }
  8922. #endif
  8923. static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
  8924. if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
  8925. #if CYTHON_COMPILING_IN_CPYTHON
  8926. if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
  8927. PyObject *result = NULL;
  8928. PyObject *args = PyTuple_New(2);
  8929. if (unlikely(!args)) return NULL;
  8930. Py_INCREF(arg1);
  8931. PyTuple_SET_ITEM(args, 0, arg1);
  8932. Py_INCREF(arg2);
  8933. PyTuple_SET_ITEM(args, 1, arg2);
  8934. if (cfunc->flag & METH_KEYWORDS)
  8935. result = __Pyx_CallCFunctionWithKeywords(cfunc, self, args, NULL);
  8936. else
  8937. result = __Pyx_CallCFunction(cfunc, self, args);
  8938. Py_DECREF(args);
  8939. return result;
  8940. }
  8941. #endif
  8942. {
  8943. PyObject *args[4] = {NULL, self, arg1, arg2};
  8944. return __Pyx_PyObject_FastCall(cfunc->method, args+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  8945. }
  8946. }
  8947. /* ParseKeywordsImpl (used by ParseKeywords) */
  8948. static int __Pyx_ValidateDuplicatePosArgs(
  8949. PyObject *kwds,
  8950. PyObject ** const argnames[],
  8951. PyObject ** const *first_kw_arg,
  8952. const char* function_name)
  8953. {
  8954. PyObject ** const *name = argnames;
  8955. while (name != first_kw_arg) {
  8956. PyObject *key = **name;
  8957. int found = PyDict_Contains(kwds, key);
  8958. if (unlikely(found)) {
  8959. if (found == 1) __Pyx_RaiseDoubleKeywordsError(function_name, key);
  8960. goto bad;
  8961. }
  8962. name++;
  8963. }
  8964. return 0;
  8965. bad:
  8966. return -1;
  8967. }
  8968. #if CYTHON_USE_UNICODE_INTERNALS
  8969. static CYTHON_INLINE int __Pyx_UnicodeKeywordsEqual(PyObject *s1, PyObject *s2) {
  8970. int kind;
  8971. Py_ssize_t len = PyUnicode_GET_LENGTH(s1);
  8972. if (len != PyUnicode_GET_LENGTH(s2)) return 0;
  8973. kind = PyUnicode_KIND(s1);
  8974. if (kind != PyUnicode_KIND(s2)) return 0;
  8975. const void *data1 = PyUnicode_DATA(s1);
  8976. const void *data2 = PyUnicode_DATA(s2);
  8977. return (memcmp(data1, data2, (size_t) len * (size_t) kind) == 0);
  8978. }
  8979. #endif
  8980. static int __Pyx_MatchKeywordArg_str(
  8981. PyObject *key,
  8982. PyObject ** const argnames[],
  8983. PyObject ** const *first_kw_arg,
  8984. size_t *index_found,
  8985. const char *function_name)
  8986. {
  8987. PyObject ** const *name;
  8988. #if CYTHON_USE_UNICODE_INTERNALS
  8989. Py_hash_t key_hash = ((PyASCIIObject*)key)->hash;
  8990. if (unlikely(key_hash == -1)) {
  8991. key_hash = PyObject_Hash(key);
  8992. if (unlikely(key_hash == -1))
  8993. goto bad;
  8994. }
  8995. #endif
  8996. name = first_kw_arg;
  8997. while (*name) {
  8998. PyObject *name_str = **name;
  8999. #if CYTHON_USE_UNICODE_INTERNALS
  9000. if (key_hash == ((PyASCIIObject*)name_str)->hash && __Pyx_UnicodeKeywordsEqual(name_str, key)) {
  9001. *index_found = (size_t) (name - argnames);
  9002. return 1;
  9003. }
  9004. #else
  9005. #if CYTHON_ASSUME_SAFE_SIZE
  9006. if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key))
  9007. #endif
  9008. {
  9009. int cmp = PyUnicode_Compare(name_str, key);
  9010. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  9011. if (cmp == 0) {
  9012. *index_found = (size_t) (name - argnames);
  9013. return 1;
  9014. }
  9015. }
  9016. #endif
  9017. name++;
  9018. }
  9019. name = argnames;
  9020. while (name != first_kw_arg) {
  9021. PyObject *name_str = **name;
  9022. #if CYTHON_USE_UNICODE_INTERNALS
  9023. if (unlikely(key_hash == ((PyASCIIObject*)name_str)->hash)) {
  9024. if (__Pyx_UnicodeKeywordsEqual(name_str, key))
  9025. goto arg_passed_twice;
  9026. }
  9027. #else
  9028. #if CYTHON_ASSUME_SAFE_SIZE
  9029. if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key))
  9030. #endif
  9031. {
  9032. if (unlikely(name_str == key)) goto arg_passed_twice;
  9033. int cmp = PyUnicode_Compare(name_str, key);
  9034. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  9035. if (cmp == 0) goto arg_passed_twice;
  9036. }
  9037. #endif
  9038. name++;
  9039. }
  9040. return 0;
  9041. arg_passed_twice:
  9042. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  9043. goto bad;
  9044. bad:
  9045. return -1;
  9046. }
  9047. static int __Pyx_MatchKeywordArg_nostr(
  9048. PyObject *key,
  9049. PyObject ** const argnames[],
  9050. PyObject ** const *first_kw_arg,
  9051. size_t *index_found,
  9052. const char *function_name)
  9053. {
  9054. PyObject ** const *name;
  9055. if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type;
  9056. name = first_kw_arg;
  9057. while (*name) {
  9058. int cmp = PyObject_RichCompareBool(**name, key, Py_EQ);
  9059. if (cmp == 1) {
  9060. *index_found = (size_t) (name - argnames);
  9061. return 1;
  9062. }
  9063. if (unlikely(cmp == -1)) goto bad;
  9064. name++;
  9065. }
  9066. name = argnames;
  9067. while (name != first_kw_arg) {
  9068. int cmp = PyObject_RichCompareBool(**name, key, Py_EQ);
  9069. if (unlikely(cmp != 0)) {
  9070. if (cmp == 1) goto arg_passed_twice;
  9071. else goto bad;
  9072. }
  9073. name++;
  9074. }
  9075. return 0;
  9076. arg_passed_twice:
  9077. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  9078. goto bad;
  9079. invalid_keyword_type:
  9080. PyErr_Format(PyExc_TypeError,
  9081. "%.200s() keywords must be strings", function_name);
  9082. goto bad;
  9083. bad:
  9084. return -1;
  9085. }
  9086. static CYTHON_INLINE int __Pyx_MatchKeywordArg(
  9087. PyObject *key,
  9088. PyObject ** const argnames[],
  9089. PyObject ** const *first_kw_arg,
  9090. size_t *index_found,
  9091. const char *function_name)
  9092. {
  9093. return likely(PyUnicode_CheckExact(key)) ?
  9094. __Pyx_MatchKeywordArg_str(key, argnames, first_kw_arg, index_found, function_name) :
  9095. __Pyx_MatchKeywordArg_nostr(key, argnames, first_kw_arg, index_found, function_name);
  9096. }
  9097. static void __Pyx_RejectUnknownKeyword(
  9098. PyObject *kwds,
  9099. PyObject ** const argnames[],
  9100. PyObject ** const *first_kw_arg,
  9101. const char *function_name)
  9102. {
  9103. #if CYTHON_AVOID_BORROWED_REFS
  9104. PyObject *pos = NULL;
  9105. #else
  9106. Py_ssize_t pos = 0;
  9107. #endif
  9108. PyObject *key = NULL;
  9109. __Pyx_BEGIN_CRITICAL_SECTION(kwds);
  9110. while (
  9111. #if CYTHON_AVOID_BORROWED_REFS
  9112. __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL)
  9113. #else
  9114. PyDict_Next(kwds, &pos, &key, NULL)
  9115. #endif
  9116. ) {
  9117. PyObject** const *name = first_kw_arg;
  9118. while (*name && (**name != key)) name++;
  9119. if (!*name) {
  9120. size_t index_found = 0;
  9121. int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name);
  9122. if (cmp != 1) {
  9123. if (cmp == 0) {
  9124. PyErr_Format(PyExc_TypeError,
  9125. "%s() got an unexpected keyword argument '%U'",
  9126. function_name, key);
  9127. }
  9128. #if CYTHON_AVOID_BORROWED_REFS
  9129. Py_DECREF(key);
  9130. #endif
  9131. break;
  9132. }
  9133. }
  9134. #if CYTHON_AVOID_BORROWED_REFS
  9135. Py_DECREF(key);
  9136. #endif
  9137. }
  9138. __Pyx_END_CRITICAL_SECTION();
  9139. #if CYTHON_AVOID_BORROWED_REFS
  9140. Py_XDECREF(pos);
  9141. #endif
  9142. assert(PyErr_Occurred());
  9143. }
  9144. static int __Pyx_ParseKeywordDict(
  9145. PyObject *kwds,
  9146. PyObject ** const argnames[],
  9147. PyObject *values[],
  9148. Py_ssize_t num_pos_args,
  9149. Py_ssize_t num_kwargs,
  9150. const char* function_name,
  9151. int ignore_unknown_kwargs)
  9152. {
  9153. PyObject** const *name;
  9154. PyObject** const *first_kw_arg = argnames + num_pos_args;
  9155. Py_ssize_t extracted = 0;
  9156. #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments)
  9157. if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1;
  9158. #endif
  9159. name = first_kw_arg;
  9160. while (*name && num_kwargs > extracted) {
  9161. PyObject * key = **name;
  9162. PyObject *value;
  9163. int found = 0;
  9164. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  9165. found = PyDict_GetItemRef(kwds, key, &value);
  9166. #else
  9167. value = PyDict_GetItemWithError(kwds, key);
  9168. if (value) {
  9169. Py_INCREF(value);
  9170. found = 1;
  9171. } else {
  9172. if (unlikely(PyErr_Occurred())) goto bad;
  9173. }
  9174. #endif
  9175. if (found) {
  9176. if (unlikely(found < 0)) goto bad;
  9177. values[name-argnames] = value;
  9178. extracted++;
  9179. }
  9180. name++;
  9181. }
  9182. if (num_kwargs > extracted) {
  9183. if (ignore_unknown_kwargs) {
  9184. if (unlikely(__Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name) == -1))
  9185. goto bad;
  9186. } else {
  9187. __Pyx_RejectUnknownKeyword(kwds, argnames, first_kw_arg, function_name);
  9188. goto bad;
  9189. }
  9190. }
  9191. return 0;
  9192. bad:
  9193. return -1;
  9194. }
  9195. static int __Pyx_ParseKeywordDictToDict(
  9196. PyObject *kwds,
  9197. PyObject ** const argnames[],
  9198. PyObject *kwds2,
  9199. PyObject *values[],
  9200. Py_ssize_t num_pos_args,
  9201. const char* function_name)
  9202. {
  9203. PyObject** const *name;
  9204. PyObject** const *first_kw_arg = argnames + num_pos_args;
  9205. Py_ssize_t len;
  9206. #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments)
  9207. if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1;
  9208. #endif
  9209. if (PyDict_Update(kwds2, kwds) < 0) goto bad;
  9210. name = first_kw_arg;
  9211. while (*name) {
  9212. PyObject *key = **name;
  9213. PyObject *value;
  9214. #if !CYTHON_COMPILING_IN_LIMITED_API && (PY_VERSION_HEX >= 0x030d00A2 || defined(PyDict_Pop))
  9215. int found = PyDict_Pop(kwds2, key, &value);
  9216. if (found) {
  9217. if (unlikely(found < 0)) goto bad;
  9218. values[name-argnames] = value;
  9219. }
  9220. #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  9221. int found = PyDict_GetItemRef(kwds2, key, &value);
  9222. if (found) {
  9223. if (unlikely(found < 0)) goto bad;
  9224. values[name-argnames] = value;
  9225. if (unlikely(PyDict_DelItem(kwds2, key) < 0)) goto bad;
  9226. }
  9227. #else
  9228. #if CYTHON_COMPILING_IN_CPYTHON
  9229. value = _PyDict_Pop(kwds2, key, kwds2);
  9230. #else
  9231. value = __Pyx_CallUnboundCMethod2(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_pop, kwds2, key, kwds2);
  9232. #endif
  9233. if (value == kwds2) {
  9234. Py_DECREF(value);
  9235. } else {
  9236. if (unlikely(!value)) goto bad;
  9237. values[name-argnames] = value;
  9238. }
  9239. #endif
  9240. name++;
  9241. }
  9242. len = PyDict_Size(kwds2);
  9243. if (len > 0) {
  9244. return __Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name);
  9245. } else if (unlikely(len == -1)) {
  9246. goto bad;
  9247. }
  9248. return 0;
  9249. bad:
  9250. return -1;
  9251. }
  9252. static int __Pyx_ParseKeywordsTuple(
  9253. PyObject *kwds,
  9254. PyObject * const *kwvalues,
  9255. PyObject ** const argnames[],
  9256. PyObject *kwds2,
  9257. PyObject *values[],
  9258. Py_ssize_t num_pos_args,
  9259. Py_ssize_t num_kwargs,
  9260. const char* function_name,
  9261. int ignore_unknown_kwargs)
  9262. {
  9263. PyObject *key = NULL;
  9264. PyObject** const * name;
  9265. PyObject** const *first_kw_arg = argnames + num_pos_args;
  9266. for (Py_ssize_t pos = 0; pos < num_kwargs; pos++) {
  9267. #if CYTHON_AVOID_BORROWED_REFS
  9268. key = __Pyx_PySequence_ITEM(kwds, pos);
  9269. #else
  9270. key = __Pyx_PyTuple_GET_ITEM(kwds, pos);
  9271. #endif
  9272. #if !CYTHON_ASSUME_SAFE_MACROS
  9273. if (unlikely(!key)) goto bad;
  9274. #endif
  9275. name = first_kw_arg;
  9276. while (*name && (**name != key)) name++;
  9277. if (*name) {
  9278. PyObject *value = kwvalues[pos];
  9279. values[name-argnames] = __Pyx_NewRef(value);
  9280. } else {
  9281. size_t index_found = 0;
  9282. int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name);
  9283. if (cmp == 1) {
  9284. PyObject *value = kwvalues[pos];
  9285. values[index_found] = __Pyx_NewRef(value);
  9286. } else {
  9287. if (unlikely(cmp == -1)) goto bad;
  9288. if (kwds2) {
  9289. PyObject *value = kwvalues[pos];
  9290. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  9291. } else if (!ignore_unknown_kwargs) {
  9292. goto invalid_keyword;
  9293. }
  9294. }
  9295. }
  9296. #if CYTHON_AVOID_BORROWED_REFS
  9297. Py_DECREF(key);
  9298. key = NULL;
  9299. #endif
  9300. }
  9301. return 0;
  9302. invalid_keyword:
  9303. PyErr_Format(PyExc_TypeError,
  9304. "%s() got an unexpected keyword argument '%U'",
  9305. function_name, key);
  9306. goto bad;
  9307. bad:
  9308. #if CYTHON_AVOID_BORROWED_REFS
  9309. Py_XDECREF(key);
  9310. #endif
  9311. return -1;
  9312. }
  9313. /* ParseKeywords */
  9314. static int __Pyx_ParseKeywords(
  9315. PyObject *kwds,
  9316. PyObject * const *kwvalues,
  9317. PyObject ** const argnames[],
  9318. PyObject *kwds2,
  9319. PyObject *values[],
  9320. Py_ssize_t num_pos_args,
  9321. Py_ssize_t num_kwargs,
  9322. const char* function_name,
  9323. int ignore_unknown_kwargs)
  9324. {
  9325. if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds)))
  9326. return __Pyx_ParseKeywordsTuple(kwds, kwvalues, argnames, kwds2, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs);
  9327. else if (kwds2)
  9328. return __Pyx_ParseKeywordDictToDict(kwds, argnames, kwds2, values, num_pos_args, function_name);
  9329. else
  9330. return __Pyx_ParseKeywordDict(kwds, argnames, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs);
  9331. }
  9332. /* RaiseArgTupleInvalid */
  9333. static void __Pyx_RaiseArgtupleInvalid(
  9334. const char* func_name,
  9335. int exact,
  9336. Py_ssize_t num_min,
  9337. Py_ssize_t num_max,
  9338. Py_ssize_t num_found)
  9339. {
  9340. Py_ssize_t num_expected;
  9341. const char *more_or_less;
  9342. if (num_found < num_min) {
  9343. num_expected = num_min;
  9344. more_or_less = "at least";
  9345. } else {
  9346. num_expected = num_max;
  9347. more_or_less = "at most";
  9348. }
  9349. if (exact) {
  9350. more_or_less = "exactly";
  9351. }
  9352. PyErr_Format(PyExc_TypeError,
  9353. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  9354. func_name, more_or_less, num_expected,
  9355. (num_expected == 1) ? "" : "s", num_found);
  9356. }
  9357. /* GetException (used by pep479) */
  9358. #if CYTHON_FAST_THREAD_STATE
  9359. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
  9360. #else
  9361. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
  9362. #endif
  9363. {
  9364. PyObject *local_type = NULL, *local_value, *local_tb = NULL;
  9365. #if CYTHON_FAST_THREAD_STATE
  9366. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9367. #if PY_VERSION_HEX >= 0x030C0000
  9368. local_value = tstate->current_exception;
  9369. tstate->current_exception = 0;
  9370. #else
  9371. local_type = tstate->curexc_type;
  9372. local_value = tstate->curexc_value;
  9373. local_tb = tstate->curexc_traceback;
  9374. tstate->curexc_type = 0;
  9375. tstate->curexc_value = 0;
  9376. tstate->curexc_traceback = 0;
  9377. #endif
  9378. #elif __PYX_LIMITED_VERSION_HEX > 0x030C0000
  9379. local_value = PyErr_GetRaisedException();
  9380. #else
  9381. PyErr_Fetch(&local_type, &local_value, &local_tb);
  9382. #endif
  9383. #if __PYX_LIMITED_VERSION_HEX > 0x030C0000
  9384. if (likely(local_value)) {
  9385. local_type = (PyObject*) Py_TYPE(local_value);
  9386. Py_INCREF(local_type);
  9387. local_tb = PyException_GetTraceback(local_value);
  9388. }
  9389. #else
  9390. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  9391. #if CYTHON_FAST_THREAD_STATE
  9392. if (unlikely(tstate->curexc_type))
  9393. #else
  9394. if (unlikely(PyErr_Occurred()))
  9395. #endif
  9396. goto bad;
  9397. if (local_tb) {
  9398. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  9399. goto bad;
  9400. }
  9401. #endif // __PYX_LIMITED_VERSION_HEX > 0x030C0000
  9402. Py_XINCREF(local_tb);
  9403. Py_XINCREF(local_type);
  9404. Py_XINCREF(local_value);
  9405. *type = local_type;
  9406. *value = local_value;
  9407. *tb = local_tb;
  9408. #if CYTHON_FAST_THREAD_STATE
  9409. #if CYTHON_USE_EXC_INFO_STACK
  9410. {
  9411. _PyErr_StackItem *exc_info = tstate->exc_info;
  9412. #if PY_VERSION_HEX >= 0x030B00a4
  9413. tmp_value = exc_info->exc_value;
  9414. exc_info->exc_value = local_value;
  9415. tmp_type = NULL;
  9416. tmp_tb = NULL;
  9417. Py_XDECREF(local_type);
  9418. Py_XDECREF(local_tb);
  9419. #else
  9420. tmp_type = exc_info->exc_type;
  9421. tmp_value = exc_info->exc_value;
  9422. tmp_tb = exc_info->exc_traceback;
  9423. exc_info->exc_type = local_type;
  9424. exc_info->exc_value = local_value;
  9425. exc_info->exc_traceback = local_tb;
  9426. #endif
  9427. }
  9428. #else
  9429. tmp_type = tstate->exc_type;
  9430. tmp_value = tstate->exc_value;
  9431. tmp_tb = tstate->exc_traceback;
  9432. tstate->exc_type = local_type;
  9433. tstate->exc_value = local_value;
  9434. tstate->exc_traceback = local_tb;
  9435. #endif
  9436. Py_XDECREF(tmp_type);
  9437. Py_XDECREF(tmp_value);
  9438. Py_XDECREF(tmp_tb);
  9439. #elif __PYX_LIMITED_VERSION_HEX >= 0x030b0000
  9440. PyErr_SetHandledException(local_value);
  9441. Py_XDECREF(local_value);
  9442. Py_XDECREF(local_type);
  9443. Py_XDECREF(local_tb);
  9444. #else
  9445. PyErr_SetExcInfo(local_type, local_value, local_tb);
  9446. #endif
  9447. return 0;
  9448. #if __PYX_LIMITED_VERSION_HEX <= 0x030C0000
  9449. bad:
  9450. *type = 0;
  9451. *value = 0;
  9452. *tb = 0;
  9453. Py_XDECREF(local_type);
  9454. Py_XDECREF(local_value);
  9455. Py_XDECREF(local_tb);
  9456. return -1;
  9457. #endif
  9458. }
  9459. /* pep479 */
  9460. static void __Pyx_Generator_Replace_StopIteration(int in_async_gen) {
  9461. PyObject *exc, *val, *tb, *cur_exc, *new_exc;
  9462. __Pyx_PyThreadState_declare
  9463. int is_async_stopiteration = 0;
  9464. CYTHON_MAYBE_UNUSED_VAR(in_async_gen);
  9465. __Pyx_PyThreadState_assign
  9466. cur_exc = __Pyx_PyErr_CurrentExceptionType();
  9467. if (likely(!__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopIteration))) {
  9468. if (in_async_gen && unlikely(__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopAsyncIteration))) {
  9469. is_async_stopiteration = 1;
  9470. } else {
  9471. return;
  9472. }
  9473. }
  9474. __Pyx_GetException(&exc, &val, &tb);
  9475. Py_XDECREF(exc);
  9476. Py_XDECREF(tb);
  9477. new_exc = PyObject_CallFunction(PyExc_RuntimeError, "s",
  9478. is_async_stopiteration ? "async generator raised StopAsyncIteration" :
  9479. in_async_gen ? "async generator raised StopIteration" :
  9480. "generator raised StopIteration");
  9481. if (!new_exc) {
  9482. Py_XDECREF(val);
  9483. return;
  9484. }
  9485. PyException_SetCause(new_exc, val); // steals ref to val
  9486. PyErr_SetObject(PyExc_RuntimeError, new_exc);
  9487. }
  9488. /* GetTopmostException (used by SaveResetException) */
  9489. #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
  9490. static _PyErr_StackItem *
  9491. __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
  9492. {
  9493. _PyErr_StackItem *exc_info = tstate->exc_info;
  9494. while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) &&
  9495. exc_info->previous_item != NULL)
  9496. {
  9497. exc_info = exc_info->previous_item;
  9498. }
  9499. return exc_info;
  9500. }
  9501. #endif
  9502. /* SaveResetException */
  9503. #if CYTHON_FAST_THREAD_STATE
  9504. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  9505. #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
  9506. _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
  9507. PyObject *exc_value = exc_info->exc_value;
  9508. if (exc_value == NULL || exc_value == Py_None) {
  9509. *value = NULL;
  9510. *type = NULL;
  9511. *tb = NULL;
  9512. } else {
  9513. *value = exc_value;
  9514. Py_INCREF(*value);
  9515. *type = (PyObject*) Py_TYPE(exc_value);
  9516. Py_INCREF(*type);
  9517. *tb = PyException_GetTraceback(exc_value);
  9518. }
  9519. #elif CYTHON_USE_EXC_INFO_STACK
  9520. _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
  9521. *type = exc_info->exc_type;
  9522. *value = exc_info->exc_value;
  9523. *tb = exc_info->exc_traceback;
  9524. Py_XINCREF(*type);
  9525. Py_XINCREF(*value);
  9526. Py_XINCREF(*tb);
  9527. #else
  9528. *type = tstate->exc_type;
  9529. *value = tstate->exc_value;
  9530. *tb = tstate->exc_traceback;
  9531. Py_XINCREF(*type);
  9532. Py_XINCREF(*value);
  9533. Py_XINCREF(*tb);
  9534. #endif
  9535. }
  9536. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  9537. #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
  9538. _PyErr_StackItem *exc_info = tstate->exc_info;
  9539. PyObject *tmp_value = exc_info->exc_value;
  9540. exc_info->exc_value = value;
  9541. Py_XDECREF(tmp_value);
  9542. Py_XDECREF(type);
  9543. Py_XDECREF(tb);
  9544. #else
  9545. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9546. #if CYTHON_USE_EXC_INFO_STACK
  9547. _PyErr_StackItem *exc_info = tstate->exc_info;
  9548. tmp_type = exc_info->exc_type;
  9549. tmp_value = exc_info->exc_value;
  9550. tmp_tb = exc_info->exc_traceback;
  9551. exc_info->exc_type = type;
  9552. exc_info->exc_value = value;
  9553. exc_info->exc_traceback = tb;
  9554. #else
  9555. tmp_type = tstate->exc_type;
  9556. tmp_value = tstate->exc_value;
  9557. tmp_tb = tstate->exc_traceback;
  9558. tstate->exc_type = type;
  9559. tstate->exc_value = value;
  9560. tstate->exc_traceback = tb;
  9561. #endif
  9562. Py_XDECREF(tmp_type);
  9563. Py_XDECREF(tmp_value);
  9564. Py_XDECREF(tmp_tb);
  9565. #endif
  9566. }
  9567. #endif
  9568. /* IterNextPlain (used by IterNext) */
  9569. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  9570. static PyObject *__Pyx_GetBuiltinNext_LimitedAPI(void) {
  9571. if (unlikely(!__pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache))
  9572. __pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache = __Pyx_GetBuiltinName(__pyx_mstate_global->__pyx_n_u_next);
  9573. return __pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache;
  9574. }
  9575. #endif
  9576. static CYTHON_INLINE PyObject *__Pyx_PyIter_Next_Plain(PyObject *iterator) {
  9577. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  9578. PyObject *result;
  9579. PyObject *next = __Pyx_GetBuiltinNext_LimitedAPI();
  9580. if (unlikely(!next)) return NULL;
  9581. result = PyObject_CallFunctionObjArgs(next, iterator, NULL);
  9582. return result;
  9583. #else
  9584. (void)__Pyx_GetBuiltinName; // only for early limited API
  9585. iternextfunc iternext = __Pyx_PyObject_GetIterNextFunc(iterator);
  9586. assert(iternext);
  9587. return iternext(iterator);
  9588. #endif
  9589. }
  9590. /* IterNext */
  9591. static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
  9592. PyObject* exc_type;
  9593. __Pyx_PyThreadState_declare
  9594. __Pyx_PyThreadState_assign
  9595. exc_type = __Pyx_PyErr_CurrentExceptionType();
  9596. if (unlikely(exc_type)) {
  9597. if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
  9598. return NULL;
  9599. __Pyx_PyErr_Clear();
  9600. Py_INCREF(defval);
  9601. return defval;
  9602. }
  9603. if (defval) {
  9604. Py_INCREF(defval);
  9605. return defval;
  9606. }
  9607. __Pyx_PyErr_SetNone(PyExc_StopIteration);
  9608. return NULL;
  9609. }
  9610. static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
  9611. __Pyx_TypeName iterator_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(iterator));
  9612. PyErr_Format(PyExc_TypeError,
  9613. __Pyx_FMT_TYPENAME " object is not an iterator", iterator_type_name);
  9614. __Pyx_DECREF_TypeName(iterator_type_name);
  9615. }
  9616. static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
  9617. PyObject* next;
  9618. #if !CYTHON_COMPILING_IN_LIMITED_API
  9619. iternextfunc iternext = __Pyx_PyObject_TryGetSlot(iterator, tp_iternext, iternextfunc);
  9620. if (likely(iternext)) {
  9621. next = iternext(iterator);
  9622. if (likely(next))
  9623. return next;
  9624. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000
  9625. if (unlikely(iternext == &_PyObject_NextNotImplemented))
  9626. return NULL;
  9627. #endif
  9628. } else if (CYTHON_USE_TYPE_SLOTS) {
  9629. __Pyx_PyIter_Next_ErrorNoIterator(iterator);
  9630. return NULL;
  9631. } else
  9632. #endif
  9633. if (unlikely(!PyIter_Check(iterator))) {
  9634. __Pyx_PyIter_Next_ErrorNoIterator(iterator);
  9635. return NULL;
  9636. } else {
  9637. next = defval ? PyIter_Next(iterator) : __Pyx_PyIter_Next_Plain(iterator);
  9638. if (likely(next))
  9639. return next;
  9640. }
  9641. return __Pyx_PyIter_Next2Default(defval);
  9642. }
  9643. /* PyLongBinop */
  9644. #if !CYTHON_COMPILING_IN_PYPY
  9645. static PyObject* __Pyx_Fallback___Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, int inplace) {
  9646. return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
  9647. }
  9648. #if CYTHON_USE_PYLONG_INTERNALS
  9649. static PyObject* __Pyx_Unpacked___Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
  9650. CYTHON_MAYBE_UNUSED_VAR(inplace);
  9651. CYTHON_UNUSED_VAR(zerodivision_check);
  9652. const long b = intval;
  9653. long a;
  9654. const PY_LONG_LONG llb = intval;
  9655. PY_LONG_LONG lla;
  9656. if (unlikely(__Pyx_PyLong_IsZero(op1))) {
  9657. return __Pyx_NewRef(op2);
  9658. }
  9659. const int is_positive = __Pyx_PyLong_IsPos(op1);
  9660. const digit* digits = __Pyx_PyLong_Digits(op1);
  9661. const Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
  9662. if (likely(size == 1)) {
  9663. a = (long) digits[0];
  9664. if (!is_positive) a *= -1;
  9665. } else {
  9666. switch (size) {
  9667. case 2:
  9668. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  9669. a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  9670. if (!is_positive) a *= -1;
  9671. goto calculate_long;
  9672. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  9673. lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  9674. if (!is_positive) lla *= -1;
  9675. goto calculate_long_long;
  9676. }
  9677. break;
  9678. case 3:
  9679. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  9680. a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  9681. if (!is_positive) a *= -1;
  9682. goto calculate_long;
  9683. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  9684. 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]));
  9685. if (!is_positive) lla *= -1;
  9686. goto calculate_long_long;
  9687. }
  9688. break;
  9689. case 4:
  9690. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  9691. a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  9692. if (!is_positive) a *= -1;
  9693. goto calculate_long;
  9694. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  9695. 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]));
  9696. if (!is_positive) lla *= -1;
  9697. goto calculate_long_long;
  9698. }
  9699. break;
  9700. }
  9701. return PyLong_Type.tp_as_number->nb_add(op1, op2);
  9702. }
  9703. calculate_long:
  9704. {
  9705. long x;
  9706. x = a + b;
  9707. return PyLong_FromLong(x);
  9708. }
  9709. calculate_long_long:
  9710. {
  9711. PY_LONG_LONG llx;
  9712. llx = lla + llb;
  9713. return PyLong_FromLongLong(llx);
  9714. }
  9715. }
  9716. #endif
  9717. static PyObject* __Pyx_Float___Pyx_PyLong_AddObjC(PyObject *float_val, long intval, int zerodivision_check) {
  9718. CYTHON_UNUSED_VAR(zerodivision_check);
  9719. const long b = intval;
  9720. double a = __Pyx_PyFloat_AS_DOUBLE(float_val);
  9721. double result;
  9722. result = ((double)a) + (double)b;
  9723. return PyFloat_FromDouble(result);
  9724. }
  9725. static CYTHON_INLINE PyObject* __Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
  9726. CYTHON_MAYBE_UNUSED_VAR(intval);
  9727. CYTHON_UNUSED_VAR(zerodivision_check);
  9728. #if CYTHON_USE_PYLONG_INTERNALS
  9729. if (likely(PyLong_CheckExact(op1))) {
  9730. return __Pyx_Unpacked___Pyx_PyLong_AddObjC(op1, op2, intval, inplace, zerodivision_check);
  9731. }
  9732. #endif
  9733. if (PyFloat_CheckExact(op1)) {
  9734. return __Pyx_Float___Pyx_PyLong_AddObjC(op1, intval, zerodivision_check);
  9735. }
  9736. return __Pyx_Fallback___Pyx_PyLong_AddObjC(op1, op2, inplace);
  9737. }
  9738. #endif
  9739. /* RaiseException */
  9740. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  9741. PyObject* owned_instance = NULL;
  9742. if (tb == Py_None) {
  9743. tb = 0;
  9744. } else if (tb && !PyTraceBack_Check(tb)) {
  9745. PyErr_SetString(PyExc_TypeError,
  9746. "raise: arg 3 must be a traceback or None");
  9747. goto bad;
  9748. }
  9749. if (value == Py_None)
  9750. value = 0;
  9751. if (PyExceptionInstance_Check(type)) {
  9752. if (value) {
  9753. PyErr_SetString(PyExc_TypeError,
  9754. "instance exception may not have a separate value");
  9755. goto bad;
  9756. }
  9757. value = type;
  9758. type = (PyObject*) Py_TYPE(value);
  9759. } else if (PyExceptionClass_Check(type)) {
  9760. PyObject *instance_class = NULL;
  9761. if (value && PyExceptionInstance_Check(value)) {
  9762. instance_class = (PyObject*) Py_TYPE(value);
  9763. if (instance_class != type) {
  9764. int is_subclass = PyObject_IsSubclass(instance_class, type);
  9765. if (!is_subclass) {
  9766. instance_class = NULL;
  9767. } else if (unlikely(is_subclass == -1)) {
  9768. goto bad;
  9769. } else {
  9770. type = instance_class;
  9771. }
  9772. }
  9773. }
  9774. if (!instance_class) {
  9775. PyObject *args;
  9776. if (!value)
  9777. args = PyTuple_New(0);
  9778. else if (PyTuple_Check(value)) {
  9779. Py_INCREF(value);
  9780. args = value;
  9781. } else
  9782. args = PyTuple_Pack(1, value);
  9783. if (!args)
  9784. goto bad;
  9785. owned_instance = PyObject_Call(type, args, NULL);
  9786. Py_DECREF(args);
  9787. if (!owned_instance)
  9788. goto bad;
  9789. value = owned_instance;
  9790. if (!PyExceptionInstance_Check(value)) {
  9791. PyErr_Format(PyExc_TypeError,
  9792. "calling %R should have returned an instance of "
  9793. "BaseException, not %R",
  9794. type, Py_TYPE(value));
  9795. goto bad;
  9796. }
  9797. }
  9798. } else {
  9799. PyErr_SetString(PyExc_TypeError,
  9800. "raise: exception class must be a subclass of BaseException");
  9801. goto bad;
  9802. }
  9803. if (cause) {
  9804. PyObject *fixed_cause;
  9805. if (cause == Py_None) {
  9806. fixed_cause = NULL;
  9807. } else if (PyExceptionClass_Check(cause)) {
  9808. fixed_cause = PyObject_CallObject(cause, NULL);
  9809. if (fixed_cause == NULL)
  9810. goto bad;
  9811. } else if (PyExceptionInstance_Check(cause)) {
  9812. fixed_cause = cause;
  9813. Py_INCREF(fixed_cause);
  9814. } else {
  9815. PyErr_SetString(PyExc_TypeError,
  9816. "exception causes must derive from "
  9817. "BaseException");
  9818. goto bad;
  9819. }
  9820. PyException_SetCause(value, fixed_cause);
  9821. }
  9822. PyErr_SetObject(type, value);
  9823. if (tb) {
  9824. #if PY_VERSION_HEX >= 0x030C00A6
  9825. PyException_SetTraceback(value, tb);
  9826. #elif CYTHON_FAST_THREAD_STATE
  9827. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  9828. PyObject* tmp_tb = tstate->curexc_traceback;
  9829. if (tb != tmp_tb) {
  9830. Py_INCREF(tb);
  9831. tstate->curexc_traceback = tb;
  9832. Py_XDECREF(tmp_tb);
  9833. }
  9834. #else
  9835. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9836. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  9837. Py_INCREF(tb);
  9838. PyErr_Restore(tmp_type, tmp_value, tb);
  9839. Py_XDECREF(tmp_tb);
  9840. #endif
  9841. }
  9842. bad:
  9843. Py_XDECREF(owned_instance);
  9844. return;
  9845. }
  9846. /* SetItemInt */
  9847. static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
  9848. int r;
  9849. if (unlikely(!j)) return -1;
  9850. r = PyObject_SetItem(o, j, v);
  9851. Py_DECREF(j);
  9852. return r;
  9853. }
  9854. static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
  9855. int wraparound, int boundscheck, int unsafe_shared) {
  9856. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  9857. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE && !CYTHON_AVOID_BORROWED_REFS
  9858. if (is_list || PyList_CheckExact(o)) {
  9859. Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
  9860. if ((CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS && !__Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared))) {
  9861. Py_INCREF(v);
  9862. return PyList_SetItem(o, n, v);
  9863. } else if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
  9864. PyObject* old;
  9865. Py_INCREF(v);
  9866. old = PyList_GET_ITEM(o, n);
  9867. PyList_SET_ITEM(o, n, v);
  9868. Py_DECREF(old);
  9869. return 0;
  9870. }
  9871. } else
  9872. #endif
  9873. #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
  9874. {
  9875. PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
  9876. PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
  9877. if (!is_list && mm && mm->mp_ass_subscript) {
  9878. int r;
  9879. PyObject *key = PyLong_FromSsize_t(i);
  9880. if (unlikely(!key)) return -1;
  9881. r = mm->mp_ass_subscript(o, key, v);
  9882. Py_DECREF(key);
  9883. return r;
  9884. }
  9885. if (is_list || likely(sm && sm->sq_ass_item)) {
  9886. if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
  9887. Py_ssize_t l = sm->sq_length(o);
  9888. if (likely(l >= 0)) {
  9889. i += l;
  9890. } else {
  9891. if (!PyErr_ExceptionMatches(PyExc_OverflowError))
  9892. return -1;
  9893. PyErr_Clear();
  9894. }
  9895. }
  9896. return sm->sq_ass_item(o, i, v);
  9897. }
  9898. }
  9899. #else
  9900. if (is_list || !PyMapping_Check(o)) {
  9901. return PySequence_SetItem(o, i, v);
  9902. }
  9903. #endif
  9904. (void)wraparound;
  9905. (void)boundscheck;
  9906. return __Pyx_SetItemInt_Generic(o, PyLong_FromSsize_t(i), v);
  9907. }
  9908. /* ModInt[long] */
  9909. static CYTHON_INLINE long __Pyx_mod_long(long a, long b, int b_is_constant) {
  9910. long r = a % b;
  9911. long adapt_python = (b_is_constant ?
  9912. ((r != 0) & ((r < 0) ^ (b < 0))) :
  9913. ((r != 0) & ((r ^ b) < 0))
  9914. );
  9915. return r + adapt_python * b;
  9916. }
  9917. /* AllocateExtensionType */
  9918. static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final) {
  9919. if (is_final || likely(!__Pyx_PyType_HasFeature(t, Py_TPFLAGS_IS_ABSTRACT))) {
  9920. allocfunc alloc_func = __Pyx_PyType_GetSlot(t, tp_alloc, allocfunc);
  9921. return alloc_func(t, 0);
  9922. } else {
  9923. newfunc tp_new = __Pyx_PyType_TryGetSlot(&PyBaseObject_Type, tp_new, newfunc);
  9924. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  9925. if (!tp_new) {
  9926. PyObject *new_str = PyUnicode_FromString("__new__");
  9927. if (likely(new_str)) {
  9928. PyObject *o = PyObject_CallMethodObjArgs((PyObject *)&PyBaseObject_Type, new_str, t, NULL);
  9929. Py_DECREF(new_str);
  9930. return o;
  9931. } else
  9932. return NULL;
  9933. } else
  9934. #endif
  9935. return tp_new(t, __pyx_mstate_global->__pyx_empty_tuple, 0);
  9936. }
  9937. }
  9938. /* LimitedApiGetTypeDict (used by SetItemOnTypeDict) */
  9939. #if CYTHON_COMPILING_IN_LIMITED_API
  9940. static Py_ssize_t __Pyx_GetTypeDictOffset(void) {
  9941. PyObject *tp_dictoffset_o;
  9942. Py_ssize_t tp_dictoffset;
  9943. tp_dictoffset_o = PyObject_GetAttrString((PyObject*)(&PyType_Type), "__dictoffset__");
  9944. if (unlikely(!tp_dictoffset_o)) return -1;
  9945. tp_dictoffset = PyLong_AsSsize_t(tp_dictoffset_o);
  9946. Py_DECREF(tp_dictoffset_o);
  9947. if (unlikely(tp_dictoffset == 0)) {
  9948. PyErr_SetString(
  9949. PyExc_TypeError,
  9950. "'type' doesn't have a dictoffset");
  9951. return -1;
  9952. } else if (unlikely(tp_dictoffset < 0)) {
  9953. PyErr_SetString(
  9954. PyExc_TypeError,
  9955. "'type' has an unexpected negative dictoffset. "
  9956. "Please report this as Cython bug");
  9957. return -1;
  9958. }
  9959. return tp_dictoffset;
  9960. }
  9961. static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp) {
  9962. static Py_ssize_t tp_dictoffset = 0;
  9963. if (unlikely(tp_dictoffset == 0)) {
  9964. tp_dictoffset = __Pyx_GetTypeDictOffset();
  9965. if (unlikely(tp_dictoffset == -1 && PyErr_Occurred())) {
  9966. tp_dictoffset = 0; // try again next time?
  9967. return NULL;
  9968. }
  9969. }
  9970. return *(PyObject**)((char*)tp + tp_dictoffset);
  9971. }
  9972. #endif
  9973. /* SetItemOnTypeDict (used by FixUpExtensionType) */
  9974. static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v) {
  9975. int result;
  9976. PyObject *tp_dict;
  9977. #if CYTHON_COMPILING_IN_LIMITED_API
  9978. tp_dict = __Pyx_GetTypeDict(tp);
  9979. if (unlikely(!tp_dict)) return -1;
  9980. #else
  9981. tp_dict = tp->tp_dict;
  9982. #endif
  9983. result = PyDict_SetItem(tp_dict, k, v);
  9984. if (likely(!result)) {
  9985. PyType_Modified(tp);
  9986. if (unlikely(PyObject_HasAttr(v, __pyx_mstate_global->__pyx_n_u_set_name))) {
  9987. PyObject *setNameResult = PyObject_CallMethodObjArgs(v, __pyx_mstate_global->__pyx_n_u_set_name, (PyObject *) tp, k, NULL);
  9988. if (!setNameResult) return -1;
  9989. Py_DECREF(setNameResult);
  9990. }
  9991. }
  9992. return result;
  9993. }
  9994. /* FixUpExtensionType */
  9995. static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) {
  9996. #if __PYX_LIMITED_VERSION_HEX > 0x030900B1
  9997. CYTHON_UNUSED_VAR(spec);
  9998. CYTHON_UNUSED_VAR(type);
  9999. CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
  10000. #else
  10001. const PyType_Slot *slot = spec->slots;
  10002. int changed = 0;
  10003. #if !CYTHON_COMPILING_IN_LIMITED_API
  10004. while (slot && slot->slot && slot->slot != Py_tp_members)
  10005. slot++;
  10006. if (slot && slot->slot == Py_tp_members) {
  10007. #if !CYTHON_COMPILING_IN_CPYTHON
  10008. const
  10009. #endif // !CYTHON_COMPILING_IN_CPYTHON)
  10010. PyMemberDef *memb = (PyMemberDef*) slot->pfunc;
  10011. while (memb && memb->name) {
  10012. if (memb->name[0] == '_' && memb->name[1] == '_') {
  10013. if (strcmp(memb->name, "__weaklistoffset__") == 0) {
  10014. assert(memb->type == T_PYSSIZET);
  10015. assert(memb->flags == READONLY);
  10016. type->tp_weaklistoffset = memb->offset;
  10017. changed = 1;
  10018. }
  10019. else if (strcmp(memb->name, "__dictoffset__") == 0) {
  10020. assert(memb->type == T_PYSSIZET);
  10021. assert(memb->flags == READONLY);
  10022. type->tp_dictoffset = memb->offset;
  10023. changed = 1;
  10024. }
  10025. #if CYTHON_METH_FASTCALL
  10026. else if (strcmp(memb->name, "__vectorcalloffset__") == 0) {
  10027. assert(memb->type == T_PYSSIZET);
  10028. assert(memb->flags == READONLY);
  10029. type->tp_vectorcall_offset = memb->offset;
  10030. changed = 1;
  10031. }
  10032. #endif // CYTHON_METH_FASTCALL
  10033. #if !CYTHON_COMPILING_IN_PYPY
  10034. else if (strcmp(memb->name, "__module__") == 0) {
  10035. PyObject *descr;
  10036. assert(memb->type == T_OBJECT);
  10037. assert(memb->flags == 0 || memb->flags == READONLY);
  10038. descr = PyDescr_NewMember(type, memb);
  10039. if (unlikely(!descr))
  10040. return -1;
  10041. int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr);
  10042. Py_DECREF(descr);
  10043. if (unlikely(set_item_result < 0)) {
  10044. return -1;
  10045. }
  10046. changed = 1;
  10047. }
  10048. #endif // !CYTHON_COMPILING_IN_PYPY
  10049. }
  10050. memb++;
  10051. }
  10052. }
  10053. #endif // !CYTHON_COMPILING_IN_LIMITED_API
  10054. #if !CYTHON_COMPILING_IN_PYPY
  10055. slot = spec->slots;
  10056. while (slot && slot->slot && slot->slot != Py_tp_getset)
  10057. slot++;
  10058. if (slot && slot->slot == Py_tp_getset) {
  10059. PyGetSetDef *getset = (PyGetSetDef*) slot->pfunc;
  10060. while (getset && getset->name) {
  10061. if (getset->name[0] == '_' && getset->name[1] == '_' && strcmp(getset->name, "__module__") == 0) {
  10062. PyObject *descr = PyDescr_NewGetSet(type, getset);
  10063. if (unlikely(!descr))
  10064. return -1;
  10065. #if CYTHON_COMPILING_IN_LIMITED_API
  10066. PyObject *pyname = PyUnicode_FromString(getset->name);
  10067. if (unlikely(!pyname)) {
  10068. Py_DECREF(descr);
  10069. return -1;
  10070. }
  10071. int set_item_result = __Pyx_SetItemOnTypeDict(type, pyname, descr);
  10072. Py_DECREF(pyname);
  10073. #else
  10074. CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
  10075. int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr);
  10076. #endif
  10077. Py_DECREF(descr);
  10078. if (unlikely(set_item_result < 0)) {
  10079. return -1;
  10080. }
  10081. changed = 1;
  10082. }
  10083. ++getset;
  10084. }
  10085. }
  10086. #else
  10087. CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
  10088. #endif // !CYTHON_COMPILING_IN_PYPY
  10089. if (changed)
  10090. PyType_Modified(type);
  10091. #endif // PY_VERSION_HEX > 0x030900B1
  10092. return 0;
  10093. }
  10094. /* PyObjectCallNoArg (used by PyObjectCallMethod0) */
  10095. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
  10096. PyObject *arg[2] = {NULL, NULL};
  10097. return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  10098. }
  10099. /* PyObjectGetMethod (used by PyObjectCallMethod0) */
  10100. #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
  10101. static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
  10102. PyObject *attr;
  10103. #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
  10104. __Pyx_TypeName type_name;
  10105. PyTypeObject *tp = Py_TYPE(obj);
  10106. PyObject *descr;
  10107. descrgetfunc f = NULL;
  10108. PyObject **dictptr, *dict;
  10109. int meth_found = 0;
  10110. assert (*method == NULL);
  10111. if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
  10112. attr = __Pyx_PyObject_GetAttrStr(obj, name);
  10113. goto try_unpack;
  10114. }
  10115. if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
  10116. return 0;
  10117. }
  10118. descr = _PyType_Lookup(tp, name);
  10119. if (likely(descr != NULL)) {
  10120. Py_INCREF(descr);
  10121. #if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR
  10122. if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR))
  10123. #else
  10124. #ifdef __Pyx_CyFunction_USED
  10125. if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
  10126. #else
  10127. if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type)))
  10128. #endif
  10129. #endif
  10130. {
  10131. meth_found = 1;
  10132. } else {
  10133. f = Py_TYPE(descr)->tp_descr_get;
  10134. if (f != NULL && PyDescr_IsData(descr)) {
  10135. attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
  10136. Py_DECREF(descr);
  10137. goto try_unpack;
  10138. }
  10139. }
  10140. }
  10141. dictptr = _PyObject_GetDictPtr(obj);
  10142. if (dictptr != NULL && (dict = *dictptr) != NULL) {
  10143. Py_INCREF(dict);
  10144. attr = __Pyx_PyDict_GetItemStr(dict, name);
  10145. if (attr != NULL) {
  10146. Py_INCREF(attr);
  10147. Py_DECREF(dict);
  10148. Py_XDECREF(descr);
  10149. goto try_unpack;
  10150. }
  10151. Py_DECREF(dict);
  10152. }
  10153. if (meth_found) {
  10154. *method = descr;
  10155. return 1;
  10156. }
  10157. if (f != NULL) {
  10158. attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
  10159. Py_DECREF(descr);
  10160. goto try_unpack;
  10161. }
  10162. if (likely(descr != NULL)) {
  10163. *method = descr;
  10164. return 0;
  10165. }
  10166. type_name = __Pyx_PyType_GetFullyQualifiedName(tp);
  10167. PyErr_Format(PyExc_AttributeError,
  10168. "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'",
  10169. type_name, name);
  10170. __Pyx_DECREF_TypeName(type_name);
  10171. return 0;
  10172. #else
  10173. attr = __Pyx_PyObject_GetAttrStr(obj, name);
  10174. goto try_unpack;
  10175. #endif
  10176. try_unpack:
  10177. #if CYTHON_UNPACK_METHODS
  10178. if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
  10179. PyObject *function = PyMethod_GET_FUNCTION(attr);
  10180. Py_INCREF(function);
  10181. Py_DECREF(attr);
  10182. *method = function;
  10183. return 1;
  10184. }
  10185. #endif
  10186. *method = attr;
  10187. return 0;
  10188. }
  10189. #endif
  10190. /* PyObjectCallMethod0 (used by PyType_Ready) */
  10191. static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
  10192. #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))
  10193. PyObject *args[1] = {obj};
  10194. (void) __Pyx_PyObject_CallOneArg;
  10195. (void) __Pyx_PyObject_CallNoArg;
  10196. return PyObject_VectorcallMethod(method_name, args, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  10197. #else
  10198. PyObject *method = NULL, *result = NULL;
  10199. int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
  10200. if (likely(is_method)) {
  10201. result = __Pyx_PyObject_CallOneArg(method, obj);
  10202. Py_DECREF(method);
  10203. return result;
  10204. }
  10205. if (unlikely(!method)) goto bad;
  10206. result = __Pyx_PyObject_CallNoArg(method);
  10207. Py_DECREF(method);
  10208. bad:
  10209. return result;
  10210. #endif
  10211. }
  10212. /* ValidateBasesTuple (used by PyType_Ready) */
  10213. #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
  10214. static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases) {
  10215. Py_ssize_t i, n;
  10216. #if CYTHON_ASSUME_SAFE_SIZE
  10217. n = PyTuple_GET_SIZE(bases);
  10218. #else
  10219. n = PyTuple_Size(bases);
  10220. if (unlikely(n < 0)) return -1;
  10221. #endif
  10222. for (i = 1; i < n; i++)
  10223. {
  10224. PyTypeObject *b;
  10225. #if CYTHON_AVOID_BORROWED_REFS
  10226. PyObject *b0 = PySequence_GetItem(bases, i);
  10227. if (!b0) return -1;
  10228. #elif CYTHON_ASSUME_SAFE_MACROS
  10229. PyObject *b0 = PyTuple_GET_ITEM(bases, i);
  10230. #else
  10231. PyObject *b0 = PyTuple_GetItem(bases, i);
  10232. if (!b0) return -1;
  10233. #endif
  10234. b = (PyTypeObject*) b0;
  10235. if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE))
  10236. {
  10237. __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b);
  10238. PyErr_Format(PyExc_TypeError,
  10239. "base class '" __Pyx_FMT_TYPENAME "' is not a heap type", b_name);
  10240. __Pyx_DECREF_TypeName(b_name);
  10241. #if CYTHON_AVOID_BORROWED_REFS
  10242. Py_DECREF(b0);
  10243. #endif
  10244. return -1;
  10245. }
  10246. if (dictoffset == 0)
  10247. {
  10248. Py_ssize_t b_dictoffset = 0;
  10249. #if CYTHON_USE_TYPE_SLOTS
  10250. b_dictoffset = b->tp_dictoffset;
  10251. #else
  10252. PyObject *py_b_dictoffset = PyObject_GetAttrString((PyObject*)b, "__dictoffset__");
  10253. if (!py_b_dictoffset) goto dictoffset_return;
  10254. b_dictoffset = PyLong_AsSsize_t(py_b_dictoffset);
  10255. Py_DECREF(py_b_dictoffset);
  10256. if (b_dictoffset == -1 && PyErr_Occurred()) goto dictoffset_return;
  10257. #endif
  10258. if (b_dictoffset) {
  10259. {
  10260. __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b);
  10261. PyErr_Format(PyExc_TypeError,
  10262. "extension type '%.200s' has no __dict__ slot, "
  10263. "but base type '" __Pyx_FMT_TYPENAME "' has: "
  10264. "either add 'cdef dict __dict__' to the extension type "
  10265. "or add '__slots__ = [...]' to the base type",
  10266. type_name, b_name);
  10267. __Pyx_DECREF_TypeName(b_name);
  10268. }
  10269. #if !CYTHON_USE_TYPE_SLOTS
  10270. dictoffset_return:
  10271. #endif
  10272. #if CYTHON_AVOID_BORROWED_REFS
  10273. Py_DECREF(b0);
  10274. #endif
  10275. return -1;
  10276. }
  10277. }
  10278. #if CYTHON_AVOID_BORROWED_REFS
  10279. Py_DECREF(b0);
  10280. #endif
  10281. }
  10282. return 0;
  10283. }
  10284. #endif
  10285. /* PyType_Ready */
  10286. CYTHON_UNUSED static int __Pyx_PyType_HasMultipleInheritance(PyTypeObject *t) {
  10287. while (t) {
  10288. PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
  10289. if (bases) {
  10290. return 1;
  10291. }
  10292. t = __Pyx_PyType_GetSlot(t, tp_base, PyTypeObject*);
  10293. }
  10294. return 0;
  10295. }
  10296. static int __Pyx_PyType_Ready(PyTypeObject *t) {
  10297. #if CYTHON_USE_TYPE_SPECS || !CYTHON_COMPILING_IN_CPYTHON || defined(PYSTON_MAJOR_VERSION)
  10298. (void)__Pyx_PyObject_CallMethod0;
  10299. #if CYTHON_USE_TYPE_SPECS
  10300. (void)__Pyx_validate_bases_tuple;
  10301. #endif
  10302. return PyType_Ready(t);
  10303. #else
  10304. int r;
  10305. if (!__Pyx_PyType_HasMultipleInheritance(t)) {
  10306. return PyType_Ready(t);
  10307. }
  10308. PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
  10309. if (bases && unlikely(__Pyx_validate_bases_tuple(t->tp_name, t->tp_dictoffset, bases) == -1))
  10310. return -1;
  10311. #if !defined(PYSTON_MAJOR_VERSION)
  10312. {
  10313. int gc_was_enabled;
  10314. #if PY_VERSION_HEX >= 0x030A00b1
  10315. gc_was_enabled = PyGC_Disable();
  10316. (void)__Pyx_PyObject_CallMethod0;
  10317. #else
  10318. PyObject *ret, *py_status;
  10319. PyObject *gc = NULL;
  10320. #if (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM+0 >= 0x07030400) &&\
  10321. !CYTHON_COMPILING_IN_GRAAL
  10322. gc = PyImport_GetModule(__pyx_mstate_global->__pyx_kp_u_gc);
  10323. #endif
  10324. if (unlikely(!gc)) gc = PyImport_Import(__pyx_mstate_global->__pyx_kp_u_gc);
  10325. if (unlikely(!gc)) return -1;
  10326. py_status = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_isenabled);
  10327. if (unlikely(!py_status)) {
  10328. Py_DECREF(gc);
  10329. return -1;
  10330. }
  10331. gc_was_enabled = __Pyx_PyObject_IsTrue(py_status);
  10332. Py_DECREF(py_status);
  10333. if (gc_was_enabled > 0) {
  10334. ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_disable);
  10335. if (unlikely(!ret)) {
  10336. Py_DECREF(gc);
  10337. return -1;
  10338. }
  10339. Py_DECREF(ret);
  10340. } else if (unlikely(gc_was_enabled == -1)) {
  10341. Py_DECREF(gc);
  10342. return -1;
  10343. }
  10344. #endif
  10345. t->tp_flags |= Py_TPFLAGS_HEAPTYPE;
  10346. #if PY_VERSION_HEX >= 0x030A0000
  10347. t->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE;
  10348. #endif
  10349. #else
  10350. (void)__Pyx_PyObject_CallMethod0;
  10351. #endif
  10352. r = PyType_Ready(t);
  10353. #if !defined(PYSTON_MAJOR_VERSION)
  10354. t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
  10355. #if PY_VERSION_HEX >= 0x030A00b1
  10356. if (gc_was_enabled)
  10357. PyGC_Enable();
  10358. #else
  10359. if (gc_was_enabled) {
  10360. PyObject *tp, *v, *tb;
  10361. PyErr_Fetch(&tp, &v, &tb);
  10362. ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_enable);
  10363. if (likely(ret || r == -1)) {
  10364. Py_XDECREF(ret);
  10365. PyErr_Restore(tp, v, tb);
  10366. } else {
  10367. Py_XDECREF(tp);
  10368. Py_XDECREF(v);
  10369. Py_XDECREF(tb);
  10370. r = -1;
  10371. }
  10372. }
  10373. Py_DECREF(gc);
  10374. #endif
  10375. }
  10376. #endif
  10377. return r;
  10378. #endif
  10379. }
  10380. /* HasAttr (used by ImportImpl) */
  10381. #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
  10382. static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
  10383. PyObject *r;
  10384. if (unlikely(!PyUnicode_Check(n))) {
  10385. PyErr_SetString(PyExc_TypeError,
  10386. "hasattr(): attribute name must be string");
  10387. return -1;
  10388. }
  10389. r = __Pyx_PyObject_GetAttrStrNoError(o, n);
  10390. if (!r) {
  10391. return (unlikely(PyErr_Occurred())) ? -1 : 0;
  10392. } else {
  10393. Py_DECREF(r);
  10394. return 1;
  10395. }
  10396. }
  10397. #endif
  10398. /* ImportImpl (used by Import) */
  10399. static int __Pyx__Import_GetModule(PyObject *qualname, PyObject **module) {
  10400. PyObject *imported_module = PyImport_GetModule(qualname);
  10401. if (unlikely(!imported_module)) {
  10402. *module = NULL;
  10403. if (PyErr_Occurred()) {
  10404. return -1;
  10405. }
  10406. return 0;
  10407. }
  10408. *module = imported_module;
  10409. return 1;
  10410. }
  10411. static int __Pyx__Import_Lookup(PyObject *qualname, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject **module) {
  10412. PyObject *imported_module;
  10413. PyObject *top_level_package_name;
  10414. Py_ssize_t i;
  10415. int status, module_found;
  10416. Py_ssize_t dot_index;
  10417. module_found = __Pyx__Import_GetModule(qualname, &imported_module);
  10418. if (unlikely(!module_found || module_found == -1)) {
  10419. *module = NULL;
  10420. return module_found;
  10421. }
  10422. if (imported_names) {
  10423. for (i = 0; i < len_imported_names; i++) {
  10424. PyObject *imported_name = imported_names[i];
  10425. #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
  10426. int has_imported_attribute = PyObject_HasAttr(imported_module, imported_name);
  10427. #else
  10428. int has_imported_attribute = PyObject_HasAttrWithError(imported_module, imported_name);
  10429. if (unlikely(has_imported_attribute == -1)) goto error;
  10430. #endif
  10431. if (!has_imported_attribute) {
  10432. goto not_found;
  10433. }
  10434. }
  10435. *module = imported_module;
  10436. return 1;
  10437. }
  10438. dot_index = PyUnicode_FindChar(qualname, '.', 0, PY_SSIZE_T_MAX, 1);
  10439. if (dot_index == -1) {
  10440. *module = imported_module;
  10441. return 1;
  10442. }
  10443. if (unlikely(dot_index == -2)) goto error;
  10444. top_level_package_name = PyUnicode_Substring(qualname, 0, dot_index);
  10445. if (unlikely(!top_level_package_name)) goto error;
  10446. Py_DECREF(imported_module);
  10447. status = __Pyx__Import_GetModule(top_level_package_name, module);
  10448. Py_DECREF(top_level_package_name);
  10449. return status;
  10450. error:
  10451. Py_DECREF(imported_module);
  10452. *module = NULL;
  10453. return -1;
  10454. not_found:
  10455. Py_DECREF(imported_module);
  10456. *module = NULL;
  10457. return 0;
  10458. }
  10459. static PyObject *__Pyx__Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, PyObject *moddict, int level) {
  10460. PyObject *module = 0;
  10461. PyObject *empty_dict = 0;
  10462. PyObject *from_list = 0;
  10463. int module_found;
  10464. if (!qualname) {
  10465. qualname = name;
  10466. }
  10467. module_found = __Pyx__Import_Lookup(qualname, imported_names, len_imported_names, &module);
  10468. if (likely(module_found == 1)) {
  10469. return module;
  10470. } else if (unlikely(module_found == -1)) {
  10471. return NULL;
  10472. }
  10473. empty_dict = PyDict_New();
  10474. if (unlikely(!empty_dict))
  10475. goto bad;
  10476. if (imported_names) {
  10477. #if CYTHON_COMPILING_IN_CPYTHON
  10478. from_list = __Pyx_PyList_FromArray(imported_names, len_imported_names);
  10479. if (unlikely(!from_list))
  10480. goto bad;
  10481. #else
  10482. from_list = PyList_New(len_imported_names);
  10483. if (unlikely(!from_list)) goto bad;
  10484. for (Py_ssize_t i=0; i<len_imported_names; ++i) {
  10485. if (PyList_SetItem(from_list, i, __Pyx_NewRef(imported_names[i])) < 0) goto bad;
  10486. }
  10487. #endif
  10488. }
  10489. if (level == -1) {
  10490. const char* package_sep = strchr(__Pyx_MODULE_NAME, '.');
  10491. if (package_sep != (0)) {
  10492. module = PyImport_ImportModuleLevelObject(
  10493. name, moddict, empty_dict, from_list, 1);
  10494. if (unlikely(!module)) {
  10495. if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError)))
  10496. goto bad;
  10497. PyErr_Clear();
  10498. }
  10499. }
  10500. level = 0;
  10501. }
  10502. if (!module) {
  10503. module = PyImport_ImportModuleLevelObject(
  10504. name, moddict, empty_dict, from_list, level);
  10505. }
  10506. bad:
  10507. Py_XDECREF(from_list);
  10508. Py_XDECREF(empty_dict);
  10509. return module;
  10510. }
  10511. /* Import */
  10512. static PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level) {
  10513. return __Pyx__Import(name, imported_names, len_imported_names, qualname, __pyx_mstate_global->__pyx_d, level);
  10514. }
  10515. /* ImportFrom */
  10516. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  10517. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  10518. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  10519. const char* module_name_str = 0;
  10520. PyObject* module_name = 0;
  10521. PyObject* module_dot = 0;
  10522. PyObject* full_name = 0;
  10523. PyErr_Clear();
  10524. module_name_str = PyModule_GetName(module);
  10525. if (unlikely(!module_name_str)) { goto modbad; }
  10526. module_name = PyUnicode_FromString(module_name_str);
  10527. if (unlikely(!module_name)) { goto modbad; }
  10528. module_dot = PyUnicode_Concat(module_name, __pyx_mstate_global->__pyx_kp_u_);
  10529. if (unlikely(!module_dot)) { goto modbad; }
  10530. full_name = PyUnicode_Concat(module_dot, name);
  10531. if (unlikely(!full_name)) { goto modbad; }
  10532. #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) ||\
  10533. CYTHON_COMPILING_IN_GRAAL
  10534. {
  10535. PyObject *modules = PyImport_GetModuleDict();
  10536. if (unlikely(!modules))
  10537. goto modbad;
  10538. value = PyObject_GetItem(modules, full_name);
  10539. }
  10540. #else
  10541. value = PyImport_GetModule(full_name);
  10542. #endif
  10543. modbad:
  10544. Py_XDECREF(full_name);
  10545. Py_XDECREF(module_dot);
  10546. Py_XDECREF(module_name);
  10547. }
  10548. if (unlikely(!value)) {
  10549. PyErr_Format(PyExc_ImportError, "cannot import name %S", name);
  10550. }
  10551. return value;
  10552. }
  10553. /* ListPack */
  10554. static PyObject *__Pyx_PyList_Pack(Py_ssize_t n, ...) {
  10555. va_list va;
  10556. PyObject *l = PyList_New(n);
  10557. va_start(va, n);
  10558. if (unlikely(!l)) goto end;
  10559. for (Py_ssize_t i=0; i<n; ++i) {
  10560. PyObject *arg = va_arg(va, PyObject*);
  10561. Py_INCREF(arg);
  10562. if (__Pyx_PyList_SET_ITEM(l, i, arg) != (0)) {
  10563. Py_CLEAR(l);
  10564. goto end;
  10565. }
  10566. }
  10567. end:
  10568. va_end(va);
  10569. return l;
  10570. }
  10571. /* pybytes_as_double (used by pyunicode_as_double) */
  10572. static double __Pyx_SlowPyString_AsDouble(PyObject *obj) {
  10573. PyObject *float_value = PyFloat_FromString(obj);
  10574. if (likely(float_value)) {
  10575. double value = __Pyx_PyFloat_AS_DOUBLE(float_value);
  10576. Py_DECREF(float_value);
  10577. return value;
  10578. }
  10579. return (double)-1;
  10580. }
  10581. static const char* __Pyx__PyBytes_AsDouble_Copy(const char* start, char* buffer, Py_ssize_t length) {
  10582. int last_was_punctuation = 1;
  10583. int parse_error_found = 0;
  10584. Py_ssize_t i;
  10585. for (i=0; i < length; i++) {
  10586. char chr = start[i];
  10587. int is_punctuation = (chr == '_') | (chr == '.') | (chr == 'e') | (chr == 'E');
  10588. *buffer = chr;
  10589. buffer += (chr != '_');
  10590. parse_error_found |= last_was_punctuation & is_punctuation;
  10591. last_was_punctuation = is_punctuation;
  10592. }
  10593. parse_error_found |= last_was_punctuation;
  10594. *buffer = '\0';
  10595. return unlikely(parse_error_found) ? NULL : buffer;
  10596. }
  10597. static double __Pyx__PyBytes_AsDouble_inf_nan(const char* start, Py_ssize_t length) {
  10598. int matches = 1;
  10599. char sign = start[0];
  10600. int is_signed = (sign == '+') | (sign == '-');
  10601. start += is_signed;
  10602. length -= is_signed;
  10603. switch (start[0]) {
  10604. #ifdef Py_NAN
  10605. case 'n':
  10606. case 'N':
  10607. if (unlikely(length != 3)) goto parse_failure;
  10608. matches &= (start[1] == 'a' || start[1] == 'A');
  10609. matches &= (start[2] == 'n' || start[2] == 'N');
  10610. if (unlikely(!matches)) goto parse_failure;
  10611. return (sign == '-') ? -Py_NAN : Py_NAN;
  10612. #endif
  10613. case 'i':
  10614. case 'I':
  10615. if (unlikely(length < 3)) goto parse_failure;
  10616. matches &= (start[1] == 'n' || start[1] == 'N');
  10617. matches &= (start[2] == 'f' || start[2] == 'F');
  10618. if (likely(length == 3 && matches))
  10619. return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL;
  10620. if (unlikely(length != 8)) goto parse_failure;
  10621. matches &= (start[3] == 'i' || start[3] == 'I');
  10622. matches &= (start[4] == 'n' || start[4] == 'N');
  10623. matches &= (start[5] == 'i' || start[5] == 'I');
  10624. matches &= (start[6] == 't' || start[6] == 'T');
  10625. matches &= (start[7] == 'y' || start[7] == 'Y');
  10626. if (unlikely(!matches)) goto parse_failure;
  10627. return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL;
  10628. case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
  10629. break;
  10630. default:
  10631. goto parse_failure;
  10632. }
  10633. return 0.0;
  10634. parse_failure:
  10635. return -1.0;
  10636. }
  10637. static CYTHON_INLINE int __Pyx__PyBytes_AsDouble_IsSpace(char ch) {
  10638. return (ch == 0x20) | !((ch < 0x9) | (ch > 0xd));
  10639. }
  10640. CYTHON_UNUSED static double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length) {
  10641. double value;
  10642. Py_ssize_t i, digits;
  10643. const char *last = start + length;
  10644. char *end;
  10645. while (__Pyx__PyBytes_AsDouble_IsSpace(*start))
  10646. start++;
  10647. while (start < last - 1 && __Pyx__PyBytes_AsDouble_IsSpace(last[-1]))
  10648. last--;
  10649. length = last - start;
  10650. if (unlikely(length <= 0)) goto fallback;
  10651. value = __Pyx__PyBytes_AsDouble_inf_nan(start, length);
  10652. if (unlikely(value == -1.0)) goto fallback;
  10653. if (value != 0.0) return value;
  10654. digits = 0;
  10655. for (i=0; i < length; digits += start[i++] != '_');
  10656. if (likely(digits == length)) {
  10657. value = PyOS_string_to_double(start, &end, NULL);
  10658. } else if (digits < 40) {
  10659. char number[40];
  10660. last = __Pyx__PyBytes_AsDouble_Copy(start, number, length);
  10661. if (unlikely(!last)) goto fallback;
  10662. value = PyOS_string_to_double(number, &end, NULL);
  10663. } else {
  10664. char *number = (char*) PyMem_Malloc((digits + 1) * sizeof(char));
  10665. if (unlikely(!number)) goto fallback;
  10666. last = __Pyx__PyBytes_AsDouble_Copy(start, number, length);
  10667. if (unlikely(!last)) {
  10668. PyMem_Free(number);
  10669. goto fallback;
  10670. }
  10671. value = PyOS_string_to_double(number, &end, NULL);
  10672. PyMem_Free(number);
  10673. }
  10674. if (likely(end == last) || (value == (double)-1 && PyErr_Occurred())) {
  10675. return value;
  10676. }
  10677. fallback:
  10678. return __Pyx_SlowPyString_AsDouble(obj);
  10679. }
  10680. /* dict_setdefault (used by FetchCommonType) */
  10681. static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value) {
  10682. PyObject* value;
  10683. #if __PYX_LIMITED_VERSION_HEX >= 0x030F0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4)
  10684. PyDict_SetDefaultRef(d, key, default_value, &value);
  10685. #elif CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX >= 0x030C0000
  10686. PyObject *args[] = {d, key, default_value};
  10687. value = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_n_u_setdefault, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  10688. #elif CYTHON_COMPILING_IN_LIMITED_API
  10689. value = PyObject_CallMethodObjArgs(d, __pyx_mstate_global->__pyx_n_u_setdefault, key, default_value, NULL);
  10690. #else
  10691. value = PyDict_SetDefault(d, key, default_value);
  10692. if (unlikely(!value)) return NULL;
  10693. Py_INCREF(value);
  10694. #endif
  10695. return value;
  10696. }
  10697. /* AddModuleRef (used by FetchSharedCythonModule) */
  10698. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  10699. static PyObject *__Pyx_PyImport_AddModuleObjectRef(PyObject *name) {
  10700. PyObject *module_dict = PyImport_GetModuleDict();
  10701. PyObject *m;
  10702. if (PyMapping_GetOptionalItem(module_dict, name, &m) < 0) {
  10703. return NULL;
  10704. }
  10705. if (m != NULL && PyModule_Check(m)) {
  10706. return m;
  10707. }
  10708. Py_XDECREF(m);
  10709. m = PyModule_NewObject(name);
  10710. if (m == NULL)
  10711. return NULL;
  10712. if (PyDict_CheckExact(module_dict)) {
  10713. PyObject *new_m;
  10714. (void)PyDict_SetDefaultRef(module_dict, name, m, &new_m);
  10715. Py_DECREF(m);
  10716. return new_m;
  10717. } else {
  10718. if (PyObject_SetItem(module_dict, name, m) != 0) {
  10719. Py_DECREF(m);
  10720. return NULL;
  10721. }
  10722. return m;
  10723. }
  10724. }
  10725. static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
  10726. PyObject *py_name = PyUnicode_FromString(name);
  10727. if (!py_name) return NULL;
  10728. PyObject *module = __Pyx_PyImport_AddModuleObjectRef(py_name);
  10729. Py_DECREF(py_name);
  10730. return module;
  10731. }
  10732. #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  10733. #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
  10734. #else
  10735. static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
  10736. PyObject *module = PyImport_AddModule(name);
  10737. Py_XINCREF(module);
  10738. return module;
  10739. }
  10740. #endif
  10741. /* FetchSharedCythonModule (used by FetchCommonType) */
  10742. static PyObject *__Pyx_FetchSharedCythonABIModule(void) {
  10743. return __Pyx_PyImport_AddModuleRef(__PYX_ABI_MODULE_NAME);
  10744. }
  10745. /* FetchCommonType (used by CommonTypesMetaclass) */
  10746. #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
  10747. static PyObject* __Pyx_PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) {
  10748. PyObject *result = __Pyx_PyType_FromModuleAndSpec(module, spec, bases);
  10749. if (result && metaclass) {
  10750. PyObject *old_tp = (PyObject*)Py_TYPE(result);
  10751. Py_INCREF((PyObject*)metaclass);
  10752. #if __PYX_LIMITED_VERSION_HEX >= 0x03090000
  10753. Py_SET_TYPE(result, metaclass);
  10754. #else
  10755. result->ob_type = metaclass;
  10756. #endif
  10757. Py_DECREF(old_tp);
  10758. }
  10759. return result;
  10760. }
  10761. #else
  10762. #define __Pyx_PyType_FromMetaclass(me, mo, s, b) PyType_FromMetaclass(me, mo, s, b)
  10763. #endif
  10764. static int __Pyx_VerifyCachedType(PyObject *cached_type,
  10765. const char *name,
  10766. Py_ssize_t expected_basicsize) {
  10767. Py_ssize_t basicsize;
  10768. if (!PyType_Check(cached_type)) {
  10769. PyErr_Format(PyExc_TypeError,
  10770. "Shared Cython type %.200s is not a type object", name);
  10771. return -1;
  10772. }
  10773. if (expected_basicsize == 0) {
  10774. return 0; // size is inherited, nothing useful to check
  10775. }
  10776. #if CYTHON_COMPILING_IN_LIMITED_API
  10777. PyObject *py_basicsize;
  10778. py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__");
  10779. if (unlikely(!py_basicsize)) return -1;
  10780. basicsize = PyLong_AsSsize_t(py_basicsize);
  10781. Py_DECREF(py_basicsize);
  10782. py_basicsize = NULL;
  10783. if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) return -1;
  10784. #else
  10785. basicsize = ((PyTypeObject*) cached_type)->tp_basicsize;
  10786. #endif
  10787. if (basicsize != expected_basicsize) {
  10788. PyErr_Format(PyExc_TypeError,
  10789. "Shared Cython type %.200s has the wrong size, try recompiling",
  10790. name);
  10791. return -1;
  10792. }
  10793. return 0;
  10794. }
  10795. static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) {
  10796. PyObject *abi_module = NULL, *cached_type = NULL, *abi_module_dict, *new_cached_type, *py_object_name;
  10797. int get_item_ref_result;
  10798. const char* object_name = strrchr(spec->name, '.');
  10799. object_name = object_name ? object_name+1 : spec->name;
  10800. py_object_name = PyUnicode_FromString(object_name);
  10801. if (!py_object_name) return NULL;
  10802. abi_module = __Pyx_FetchSharedCythonABIModule();
  10803. if (!abi_module) goto done;
  10804. abi_module_dict = PyModule_GetDict(abi_module);
  10805. if (!abi_module_dict) goto done;
  10806. get_item_ref_result = __Pyx_PyDict_GetItemRef(abi_module_dict, py_object_name, &cached_type);
  10807. if (get_item_ref_result == 1) {
  10808. if (__Pyx_VerifyCachedType(
  10809. cached_type,
  10810. object_name,
  10811. spec->basicsize) < 0) {
  10812. goto bad;
  10813. }
  10814. goto done;
  10815. } else if (unlikely(get_item_ref_result == -1)) {
  10816. goto bad;
  10817. }
  10818. cached_type = __Pyx_PyType_FromMetaclass(
  10819. metaclass,
  10820. CYTHON_USE_MODULE_STATE ? module : abi_module,
  10821. spec, bases);
  10822. if (unlikely(!cached_type)) goto bad;
  10823. if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad;
  10824. new_cached_type = __Pyx_PyDict_SetDefault(abi_module_dict, py_object_name, cached_type);
  10825. if (unlikely(new_cached_type != cached_type)) {
  10826. if (unlikely(!new_cached_type)) goto bad;
  10827. Py_DECREF(cached_type);
  10828. cached_type = new_cached_type;
  10829. if (__Pyx_VerifyCachedType(
  10830. cached_type,
  10831. object_name,
  10832. spec->basicsize) < 0) {
  10833. goto bad;
  10834. }
  10835. goto done;
  10836. } else {
  10837. Py_DECREF(new_cached_type);
  10838. }
  10839. done:
  10840. Py_XDECREF(abi_module);
  10841. Py_DECREF(py_object_name);
  10842. assert(cached_type == NULL || PyType_Check(cached_type));
  10843. return (PyTypeObject *) cached_type;
  10844. bad:
  10845. Py_XDECREF(cached_type);
  10846. cached_type = NULL;
  10847. goto done;
  10848. }
  10849. /* CommonTypesMetaclass (used by CythonFunctionShared) */
  10850. static PyObject* __pyx_CommonTypesMetaclass_get_module(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED void* context) {
  10851. return PyUnicode_FromString(__PYX_ABI_MODULE_NAME);
  10852. }
  10853. #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
  10854. static PyObject* __pyx_CommonTypesMetaclass_call(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwds) {
  10855. PyErr_SetString(PyExc_TypeError, "Cannot instantiate Cython internal types");
  10856. return NULL;
  10857. }
  10858. static int __pyx_CommonTypesMetaclass_setattr(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *attr, CYTHON_UNUSED PyObject *value) {
  10859. PyErr_SetString(PyExc_TypeError, "Cython internal types are immutable");
  10860. return -1;
  10861. }
  10862. #endif
  10863. static PyGetSetDef __pyx_CommonTypesMetaclass_getset[] = {
  10864. {"__module__", __pyx_CommonTypesMetaclass_get_module, NULL, NULL, NULL},
  10865. {0, 0, 0, 0, 0}
  10866. };
  10867. static PyType_Slot __pyx_CommonTypesMetaclass_slots[] = {
  10868. {Py_tp_getset, (void *)__pyx_CommonTypesMetaclass_getset},
  10869. #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
  10870. {Py_tp_call, (void*)__pyx_CommonTypesMetaclass_call},
  10871. {Py_tp_new, (void*)__pyx_CommonTypesMetaclass_call},
  10872. {Py_tp_setattro, (void*)__pyx_CommonTypesMetaclass_setattr},
  10873. #endif
  10874. {0, 0}
  10875. };
  10876. static PyType_Spec __pyx_CommonTypesMetaclass_spec = {
  10877. __PYX_TYPE_MODULE_PREFIX "_common_types_metatype",
  10878. 0,
  10879. 0,
  10880. Py_TPFLAGS_IMMUTABLETYPE |
  10881. Py_TPFLAGS_DISALLOW_INSTANTIATION |
  10882. Py_TPFLAGS_DEFAULT,
  10883. __pyx_CommonTypesMetaclass_slots
  10884. };
  10885. static int __pyx_CommonTypesMetaclass_init(PyObject *module) {
  10886. __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
  10887. PyObject *bases = PyTuple_Pack(1, &PyType_Type);
  10888. if (unlikely(!bases)) {
  10889. return -1;
  10890. }
  10891. mstate->__pyx_CommonTypesMetaclassType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx_CommonTypesMetaclass_spec, bases);
  10892. Py_DECREF(bases);
  10893. if (unlikely(mstate->__pyx_CommonTypesMetaclassType == NULL)) {
  10894. return -1;
  10895. }
  10896. return 0;
  10897. }
  10898. /* CallTypeTraverse (used by CythonFunctionShared) */
  10899. #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000)
  10900. #else
  10901. static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg) {
  10902. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x03090000
  10903. if (__Pyx_get_runtime_version() < 0x03090000) return 0;
  10904. #endif
  10905. if (!always_call) {
  10906. PyTypeObject *base = __Pyx_PyObject_GetSlot(o, tp_base, PyTypeObject*);
  10907. unsigned long flags = PyType_GetFlags(base);
  10908. if (flags & Py_TPFLAGS_HEAPTYPE) {
  10909. return 0;
  10910. }
  10911. }
  10912. Py_VISIT((PyObject*)Py_TYPE(o));
  10913. return 0;
  10914. }
  10915. #endif
  10916. /* PyMethodNew (used by CythonFunctionShared) */
  10917. #if CYTHON_COMPILING_IN_LIMITED_API
  10918. static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
  10919. PyObject *result;
  10920. CYTHON_UNUSED_VAR(typ);
  10921. if (!self)
  10922. return __Pyx_NewRef(func);
  10923. #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
  10924. {
  10925. PyObject *args[] = {func, self};
  10926. result = PyObject_Vectorcall(__pyx_mstate_global->__Pyx_CachedMethodType, args, 2, NULL);
  10927. }
  10928. #else
  10929. result = PyObject_CallFunctionObjArgs(__pyx_mstate_global->__Pyx_CachedMethodType, func, self, NULL);
  10930. #endif
  10931. return result;
  10932. }
  10933. #else
  10934. static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
  10935. CYTHON_UNUSED_VAR(typ);
  10936. if (!self)
  10937. return __Pyx_NewRef(func);
  10938. return PyMethod_New(func, self);
  10939. }
  10940. #endif
  10941. /* PyVectorcallFastCallDict (used by CythonFunctionShared) */
  10942. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  10943. static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
  10944. {
  10945. PyObject *res = NULL;
  10946. PyObject *kwnames;
  10947. PyObject **newargs;
  10948. PyObject **kwvalues;
  10949. Py_ssize_t i;
  10950. #if CYTHON_AVOID_BORROWED_REFS
  10951. PyObject *pos;
  10952. #else
  10953. Py_ssize_t pos;
  10954. #endif
  10955. size_t j;
  10956. PyObject *key, *value;
  10957. unsigned long keys_are_strings;
  10958. #if !CYTHON_ASSUME_SAFE_SIZE
  10959. Py_ssize_t nkw = PyDict_Size(kw);
  10960. if (unlikely(nkw == -1)) return NULL;
  10961. #else
  10962. Py_ssize_t nkw = PyDict_GET_SIZE(kw);
  10963. #endif
  10964. newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0]));
  10965. if (unlikely(newargs == NULL)) {
  10966. PyErr_NoMemory();
  10967. return NULL;
  10968. }
  10969. for (j = 0; j < nargs; j++) newargs[j] = args[j];
  10970. kwnames = PyTuple_New(nkw);
  10971. if (unlikely(kwnames == NULL)) {
  10972. PyMem_Free(newargs);
  10973. return NULL;
  10974. }
  10975. kwvalues = newargs + nargs;
  10976. pos = 0;
  10977. i = 0;
  10978. keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS;
  10979. while (__Pyx_PyDict_NextRef(kw, &pos, &key, &value)) {
  10980. keys_are_strings &=
  10981. #if CYTHON_COMPILING_IN_LIMITED_API
  10982. PyType_GetFlags(Py_TYPE(key));
  10983. #else
  10984. Py_TYPE(key)->tp_flags;
  10985. #endif
  10986. #if !CYTHON_ASSUME_SAFE_MACROS
  10987. if (unlikely(PyTuple_SetItem(kwnames, i, key) < 0)) goto cleanup;
  10988. #else
  10989. PyTuple_SET_ITEM(kwnames, i, key);
  10990. #endif
  10991. kwvalues[i] = value;
  10992. i++;
  10993. }
  10994. if (unlikely(!keys_are_strings)) {
  10995. PyErr_SetString(PyExc_TypeError, "keywords must be strings");
  10996. goto cleanup;
  10997. }
  10998. res = vc(func, newargs, nargs, kwnames);
  10999. cleanup:
  11000. #if CYTHON_AVOID_BORROWED_REFS
  11001. Py_DECREF(pos);
  11002. #endif
  11003. Py_DECREF(kwnames);
  11004. for (i = 0; i < nkw; i++)
  11005. Py_DECREF(kwvalues[i]);
  11006. PyMem_Free(newargs);
  11007. return res;
  11008. }
  11009. static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
  11010. {
  11011. Py_ssize_t kw_size =
  11012. likely(kw == NULL) ?
  11013. 0 :
  11014. #if !CYTHON_ASSUME_SAFE_SIZE
  11015. PyDict_Size(kw);
  11016. #else
  11017. PyDict_GET_SIZE(kw);
  11018. #endif
  11019. if (kw_size == 0) {
  11020. return vc(func, args, nargs, NULL);
  11021. }
  11022. #if !CYTHON_ASSUME_SAFE_SIZE
  11023. else if (unlikely(kw_size == -1)) {
  11024. return NULL;
  11025. }
  11026. #endif
  11027. return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw);
  11028. }
  11029. #endif
  11030. /* CythonFunctionShared (used by CythonFunction) */
  11031. #if CYTHON_COMPILING_IN_LIMITED_API
  11032. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunctionNoMethod(PyObject *func, void (*cfunc)(void)) {
  11033. if (__Pyx_CyFunction_Check(func)) {
  11034. return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc;
  11035. } else if (PyCFunction_Check(func)) {
  11036. return PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
  11037. }
  11038. return 0;
  11039. }
  11040. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
  11041. if ((PyObject*)Py_TYPE(func) == __pyx_mstate_global->__Pyx_CachedMethodType) {
  11042. int result;
  11043. PyObject *newFunc = PyObject_GetAttr(func, __pyx_mstate_global->__pyx_n_u_func);
  11044. if (unlikely(!newFunc)) {
  11045. PyErr_Clear(); // It's only an optimization, so don't throw an error
  11046. return 0;
  11047. }
  11048. result = __Pyx__IsSameCyOrCFunctionNoMethod(newFunc, cfunc);
  11049. Py_DECREF(newFunc);
  11050. return result;
  11051. }
  11052. return __Pyx__IsSameCyOrCFunctionNoMethod(func, cfunc);
  11053. }
  11054. #else
  11055. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
  11056. if (PyMethod_Check(func)) {
  11057. func = PyMethod_GET_FUNCTION(func);
  11058. }
  11059. return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
  11060. }
  11061. #endif
  11062. static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) {
  11063. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  11064. __Pyx_Py_XDECREF_SET(
  11065. __Pyx_CyFunction_GetClassObj(f),
  11066. ((classobj) ? __Pyx_NewRef(classobj) : NULL));
  11067. #else
  11068. __Pyx_Py_XDECREF_SET(
  11069. ((PyCMethodObject *) (f))->mm_class,
  11070. (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL));
  11071. #endif
  11072. }
  11073. static PyObject *
  11074. __Pyx_CyFunction_get_doc_locked(__pyx_CyFunctionObject *op)
  11075. {
  11076. if (unlikely(op->func_doc == NULL)) {
  11077. #if CYTHON_COMPILING_IN_LIMITED_API
  11078. op->func_doc = PyObject_GetAttrString(op->func, "__doc__");
  11079. if (unlikely(!op->func_doc)) return NULL;
  11080. #else
  11081. if (((PyCFunctionObject*)op)->m_ml->ml_doc) {
  11082. op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc);
  11083. if (unlikely(op->func_doc == NULL))
  11084. return NULL;
  11085. } else {
  11086. Py_INCREF(Py_None);
  11087. return Py_None;
  11088. }
  11089. #endif
  11090. }
  11091. Py_INCREF(op->func_doc);
  11092. return op->func_doc;
  11093. }
  11094. static PyObject *
  11095. __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) {
  11096. PyObject *result;
  11097. CYTHON_UNUSED_VAR(closure);
  11098. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11099. result = __Pyx_CyFunction_get_doc_locked(op);
  11100. __Pyx_END_CRITICAL_SECTION();
  11101. return result;
  11102. }
  11103. static int
  11104. __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  11105. {
  11106. CYTHON_UNUSED_VAR(context);
  11107. if (value == NULL) {
  11108. value = Py_None;
  11109. }
  11110. Py_INCREF(value);
  11111. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11112. __Pyx_Py_XDECREF_SET(op->func_doc, value);
  11113. __Pyx_END_CRITICAL_SECTION();
  11114. return 0;
  11115. }
  11116. static PyObject *
  11117. __Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op)
  11118. {
  11119. if (unlikely(op->func_name == NULL)) {
  11120. #if CYTHON_COMPILING_IN_LIMITED_API
  11121. op->func_name = PyObject_GetAttrString(op->func, "__name__");
  11122. #else
  11123. op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name);
  11124. #endif
  11125. if (unlikely(op->func_name == NULL))
  11126. return NULL;
  11127. }
  11128. Py_INCREF(op->func_name);
  11129. return op->func_name;
  11130. }
  11131. static PyObject *
  11132. __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context)
  11133. {
  11134. PyObject *result = NULL;
  11135. CYTHON_UNUSED_VAR(context);
  11136. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11137. result = __Pyx_CyFunction_get_name_locked(op);
  11138. __Pyx_END_CRITICAL_SECTION();
  11139. return result;
  11140. }
  11141. static int
  11142. __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  11143. {
  11144. CYTHON_UNUSED_VAR(context);
  11145. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  11146. PyErr_SetString(PyExc_TypeError,
  11147. "__name__ must be set to a string object");
  11148. return -1;
  11149. }
  11150. Py_INCREF(value);
  11151. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11152. __Pyx_Py_XDECREF_SET(op->func_name, value);
  11153. __Pyx_END_CRITICAL_SECTION();
  11154. return 0;
  11155. }
  11156. static PyObject *
  11157. __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context)
  11158. {
  11159. CYTHON_UNUSED_VAR(context);
  11160. PyObject *result;
  11161. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11162. Py_INCREF(op->func_qualname);
  11163. result = op->func_qualname;
  11164. __Pyx_END_CRITICAL_SECTION();
  11165. return result;
  11166. }
  11167. static int
  11168. __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  11169. {
  11170. CYTHON_UNUSED_VAR(context);
  11171. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  11172. PyErr_SetString(PyExc_TypeError,
  11173. "__qualname__ must be set to a string object");
  11174. return -1;
  11175. }
  11176. Py_INCREF(value);
  11177. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11178. __Pyx_Py_XDECREF_SET(op->func_qualname, value);
  11179. __Pyx_END_CRITICAL_SECTION();
  11180. return 0;
  11181. }
  11182. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  11183. static PyObject *
  11184. __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context)
  11185. {
  11186. CYTHON_UNUSED_VAR(context);
  11187. if (unlikely(op->func_dict == NULL)) {
  11188. op->func_dict = PyDict_New();
  11189. if (unlikely(op->func_dict == NULL))
  11190. return NULL;
  11191. }
  11192. Py_INCREF(op->func_dict);
  11193. return op->func_dict;
  11194. }
  11195. #endif
  11196. static PyObject *
  11197. __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context)
  11198. {
  11199. CYTHON_UNUSED_VAR(context);
  11200. Py_INCREF(op->func_globals);
  11201. return op->func_globals;
  11202. }
  11203. static PyObject *
  11204. __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context)
  11205. {
  11206. CYTHON_UNUSED_VAR(op);
  11207. CYTHON_UNUSED_VAR(context);
  11208. Py_INCREF(Py_None);
  11209. return Py_None;
  11210. }
  11211. static PyObject *
  11212. __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context)
  11213. {
  11214. PyObject* result = (op->func_code) ? op->func_code : Py_None;
  11215. CYTHON_UNUSED_VAR(context);
  11216. Py_INCREF(result);
  11217. return result;
  11218. }
  11219. static int
  11220. __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
  11221. int result = 0;
  11222. PyObject *res = op->defaults_getter((PyObject *) op);
  11223. if (unlikely(!res))
  11224. return -1;
  11225. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  11226. op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
  11227. Py_INCREF(op->defaults_tuple);
  11228. op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
  11229. Py_INCREF(op->defaults_kwdict);
  11230. #else
  11231. op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0);
  11232. if (unlikely(!op->defaults_tuple)) result = -1;
  11233. else {
  11234. op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1);
  11235. if (unlikely(!op->defaults_kwdict)) result = -1;
  11236. }
  11237. #endif
  11238. Py_DECREF(res);
  11239. return result;
  11240. }
  11241. static int
  11242. __Pyx_CyFunction_set_defaults(__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 && !PyTuple_Check(value))) {
  11247. PyErr_SetString(PyExc_TypeError,
  11248. "__defaults__ must be set to a tuple object");
  11249. return -1;
  11250. }
  11251. PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ 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_tuple, value);
  11256. __Pyx_END_CRITICAL_SECTION();
  11257. return 0;
  11258. }
  11259. static PyObject *
  11260. __Pyx_CyFunction_get_defaults_locked(__pyx_CyFunctionObject *op) {
  11261. PyObject* result = op->defaults_tuple;
  11262. if (unlikely(!result)) {
  11263. if (op->defaults_getter) {
  11264. if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
  11265. result = op->defaults_tuple;
  11266. } else {
  11267. result = Py_None;
  11268. }
  11269. }
  11270. Py_INCREF(result);
  11271. return result;
  11272. }
  11273. static PyObject *
  11274. __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) {
  11275. PyObject* result = NULL;
  11276. CYTHON_UNUSED_VAR(context);
  11277. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11278. result = __Pyx_CyFunction_get_defaults_locked(op);
  11279. __Pyx_END_CRITICAL_SECTION();
  11280. return result;
  11281. }
  11282. static int
  11283. __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  11284. CYTHON_UNUSED_VAR(context);
  11285. if (!value) {
  11286. value = Py_None;
  11287. } else if (unlikely(value != Py_None && !PyDict_Check(value))) {
  11288. PyErr_SetString(PyExc_TypeError,
  11289. "__kwdefaults__ must be set to a dict object");
  11290. return -1;
  11291. }
  11292. PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not "
  11293. "currently affect the values used in function calls", 1);
  11294. Py_INCREF(value);
  11295. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11296. __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value);
  11297. __Pyx_END_CRITICAL_SECTION();
  11298. return 0;
  11299. }
  11300. static PyObject *
  11301. __Pyx_CyFunction_get_kwdefaults_locked(__pyx_CyFunctionObject *op) {
  11302. PyObject* result = op->defaults_kwdict;
  11303. if (unlikely(!result)) {
  11304. if (op->defaults_getter) {
  11305. if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
  11306. result = op->defaults_kwdict;
  11307. } else {
  11308. result = Py_None;
  11309. }
  11310. }
  11311. Py_INCREF(result);
  11312. return result;
  11313. }
  11314. static PyObject *
  11315. __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) {
  11316. PyObject* result;
  11317. CYTHON_UNUSED_VAR(context);
  11318. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11319. result = __Pyx_CyFunction_get_kwdefaults_locked(op);
  11320. __Pyx_END_CRITICAL_SECTION();
  11321. return result;
  11322. }
  11323. static int
  11324. __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  11325. CYTHON_UNUSED_VAR(context);
  11326. if (!value || value == Py_None) {
  11327. value = NULL;
  11328. } else if (unlikely(!PyDict_Check(value))) {
  11329. PyErr_SetString(PyExc_TypeError,
  11330. "__annotations__ must be set to a dict object");
  11331. return -1;
  11332. }
  11333. Py_XINCREF(value);
  11334. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11335. __Pyx_Py_XDECREF_SET(op->func_annotations, value);
  11336. __Pyx_END_CRITICAL_SECTION();
  11337. return 0;
  11338. }
  11339. static PyObject *
  11340. __Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) {
  11341. PyObject* result = op->func_annotations;
  11342. if (unlikely(!result)) {
  11343. result = PyDict_New();
  11344. if (unlikely(!result)) return NULL;
  11345. op->func_annotations = result;
  11346. }
  11347. Py_INCREF(result);
  11348. return result;
  11349. }
  11350. static PyObject *
  11351. __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) {
  11352. PyObject *result;
  11353. CYTHON_UNUSED_VAR(context);
  11354. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11355. result = __Pyx_CyFunction_get_annotations_locked(op);
  11356. __Pyx_END_CRITICAL_SECTION();
  11357. return result;
  11358. }
  11359. static PyObject *
  11360. __Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) {
  11361. int is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE;
  11362. if (is_coroutine) {
  11363. PyObject *is_coroutine_value, *module, *fromlist, *marker = __pyx_mstate_global->__pyx_n_u_is_coroutine;
  11364. fromlist = PyList_New(1);
  11365. if (unlikely(!fromlist)) return NULL;
  11366. Py_INCREF(marker);
  11367. #if CYTHON_ASSUME_SAFE_MACROS
  11368. PyList_SET_ITEM(fromlist, 0, marker);
  11369. #else
  11370. if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) {
  11371. Py_DECREF(marker);
  11372. Py_DECREF(fromlist);
  11373. return NULL;
  11374. }
  11375. #endif
  11376. module = PyImport_ImportModuleLevelObject(__pyx_mstate_global->__pyx_n_u_asyncio_coroutines, NULL, NULL, fromlist, 0);
  11377. Py_DECREF(fromlist);
  11378. if (unlikely(!module)) goto ignore;
  11379. is_coroutine_value = __Pyx_PyObject_GetAttrStr(module, marker);
  11380. Py_DECREF(module);
  11381. if (likely(is_coroutine_value)) {
  11382. return is_coroutine_value;
  11383. }
  11384. ignore:
  11385. PyErr_Clear();
  11386. }
  11387. return __Pyx_PyBool_FromLong(is_coroutine);
  11388. }
  11389. static PyObject *
  11390. __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) {
  11391. PyObject *result;
  11392. CYTHON_UNUSED_VAR(context);
  11393. if (op->func_is_coroutine) {
  11394. return __Pyx_NewRef(op->func_is_coroutine);
  11395. }
  11396. result = __Pyx_CyFunction_get_is_coroutine_value(op);
  11397. if (unlikely(!result))
  11398. return NULL;
  11399. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11400. if (op->func_is_coroutine) {
  11401. Py_DECREF(result);
  11402. result = __Pyx_NewRef(op->func_is_coroutine);
  11403. } else {
  11404. op->func_is_coroutine = __Pyx_NewRef(result);
  11405. }
  11406. __Pyx_END_CRITICAL_SECTION();
  11407. return result;
  11408. }
  11409. static void __Pyx_CyFunction_raise_argument_count_error(__pyx_CyFunctionObject *func, const char* message, Py_ssize_t size) {
  11410. #if CYTHON_COMPILING_IN_LIMITED_API
  11411. PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
  11412. if (!py_name) return;
  11413. PyErr_Format(PyExc_TypeError,
  11414. "%.200S() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  11415. py_name, message, size);
  11416. Py_DECREF(py_name);
  11417. #else
  11418. const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
  11419. PyErr_Format(PyExc_TypeError,
  11420. "%.200s() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  11421. name, message, size);
  11422. #endif
  11423. }
  11424. static void __Pyx_CyFunction_raise_type_error(__pyx_CyFunctionObject *func, const char* message) {
  11425. #if CYTHON_COMPILING_IN_LIMITED_API
  11426. PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
  11427. if (!py_name) return;
  11428. PyErr_Format(PyExc_TypeError,
  11429. "%.200S() %s",
  11430. py_name, message);
  11431. Py_DECREF(py_name);
  11432. #else
  11433. const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
  11434. PyErr_Format(PyExc_TypeError,
  11435. "%.200s() %s",
  11436. name, message);
  11437. #endif
  11438. }
  11439. #if CYTHON_COMPILING_IN_LIMITED_API
  11440. static PyObject *
  11441. __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) {
  11442. CYTHON_UNUSED_VAR(context);
  11443. return PyObject_GetAttrString(op->func, "__module__");
  11444. }
  11445. static int
  11446. __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  11447. CYTHON_UNUSED_VAR(context);
  11448. return PyObject_SetAttrString(op->func, "__module__", value);
  11449. }
  11450. #endif
  11451. static PyGetSetDef __pyx_CyFunction_getsets[] = {
  11452. {"func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  11453. {"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  11454. {"func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  11455. {"__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  11456. {"__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
  11457. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  11458. {"func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
  11459. {"__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
  11460. #else
  11461. {"func_dict", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
  11462. {"__dict__", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
  11463. #endif
  11464. {"func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  11465. {"__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  11466. {"func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  11467. {"__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  11468. {"func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  11469. {"__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  11470. {"func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  11471. {"__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  11472. {"__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
  11473. {"__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
  11474. {"_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0},
  11475. #if CYTHON_COMPILING_IN_LIMITED_API
  11476. {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0},
  11477. #endif
  11478. {0, 0, 0, 0, 0}
  11479. };
  11480. static PyMemberDef __pyx_CyFunction_members[] = {
  11481. #if !CYTHON_COMPILING_IN_LIMITED_API
  11482. {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0},
  11483. #endif
  11484. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  11485. {"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0},
  11486. #endif
  11487. #if CYTHON_METH_FASTCALL
  11488. #if CYTHON_COMPILING_IN_LIMITED_API
  11489. {"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0},
  11490. #else
  11491. {"__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0},
  11492. #endif
  11493. #if CYTHON_COMPILING_IN_LIMITED_API
  11494. {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0},
  11495. #else
  11496. {"__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0},
  11497. #endif
  11498. #endif
  11499. {0, 0, 0, 0, 0}
  11500. };
  11501. static PyObject *
  11502. __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args)
  11503. {
  11504. PyObject *result = NULL;
  11505. CYTHON_UNUSED_VAR(args);
  11506. __Pyx_BEGIN_CRITICAL_SECTION(m);
  11507. Py_INCREF(m->func_qualname);
  11508. result = m->func_qualname;
  11509. __Pyx_END_CRITICAL_SECTION();
  11510. return result;
  11511. }
  11512. static PyMethodDef __pyx_CyFunction_methods[] = {
  11513. {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
  11514. {0, 0, 0, 0}
  11515. };
  11516. #if CYTHON_COMPILING_IN_LIMITED_API
  11517. #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
  11518. #else
  11519. #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist)
  11520. #endif
  11521. static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
  11522. PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  11523. #if !CYTHON_COMPILING_IN_LIMITED_API
  11524. PyCFunctionObject *cf = (PyCFunctionObject*) op;
  11525. #endif
  11526. if (unlikely(op == NULL))
  11527. return NULL;
  11528. #if CYTHON_COMPILING_IN_LIMITED_API
  11529. op->func = PyCFunction_NewEx(ml, (PyObject*)op, module);
  11530. if (unlikely(!op->func)) return NULL;
  11531. #endif
  11532. op->flags = flags;
  11533. __Pyx_CyFunction_weakreflist(op) = NULL;
  11534. #if !CYTHON_COMPILING_IN_LIMITED_API
  11535. cf->m_ml = ml;
  11536. cf->m_self = (PyObject *) op;
  11537. #endif
  11538. Py_XINCREF(closure);
  11539. op->func_closure = closure;
  11540. #if !CYTHON_COMPILING_IN_LIMITED_API
  11541. Py_XINCREF(module);
  11542. cf->m_module = module;
  11543. #endif
  11544. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  11545. op->func_dict = NULL;
  11546. #endif
  11547. op->func_name = NULL;
  11548. Py_INCREF(qualname);
  11549. op->func_qualname = qualname;
  11550. op->func_doc = NULL;
  11551. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  11552. op->func_classobj = NULL;
  11553. #else
  11554. ((PyCMethodObject*)op)->mm_class = NULL;
  11555. #endif
  11556. op->func_globals = globals;
  11557. Py_INCREF(op->func_globals);
  11558. Py_XINCREF(code);
  11559. op->func_code = code;
  11560. op->defaults = NULL;
  11561. op->defaults_tuple = NULL;
  11562. op->defaults_kwdict = NULL;
  11563. op->defaults_getter = NULL;
  11564. op->func_annotations = NULL;
  11565. op->func_is_coroutine = NULL;
  11566. #if CYTHON_METH_FASTCALL
  11567. switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) {
  11568. case METH_NOARGS:
  11569. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS;
  11570. break;
  11571. case METH_O:
  11572. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O;
  11573. break;
  11574. case METH_METHOD | METH_FASTCALL | METH_KEYWORDS:
  11575. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD;
  11576. break;
  11577. case METH_FASTCALL | METH_KEYWORDS:
  11578. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS;
  11579. break;
  11580. case METH_VARARGS | METH_KEYWORDS:
  11581. __Pyx_CyFunction_func_vectorcall(op) = NULL;
  11582. break;
  11583. default:
  11584. PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
  11585. Py_DECREF(op);
  11586. return NULL;
  11587. }
  11588. #endif
  11589. return (PyObject *) op;
  11590. }
  11591. static int
  11592. __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
  11593. {
  11594. Py_CLEAR(m->func_closure);
  11595. #if CYTHON_COMPILING_IN_LIMITED_API
  11596. Py_CLEAR(m->func);
  11597. #else
  11598. Py_CLEAR(((PyCFunctionObject*)m)->m_module);
  11599. #endif
  11600. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  11601. Py_CLEAR(m->func_dict);
  11602. #elif PY_VERSION_HEX < 0x030d0000
  11603. _PyObject_ClearManagedDict((PyObject*)m);
  11604. #else
  11605. PyObject_ClearManagedDict((PyObject*)m);
  11606. #endif
  11607. Py_CLEAR(m->func_name);
  11608. Py_CLEAR(m->func_qualname);
  11609. Py_CLEAR(m->func_doc);
  11610. Py_CLEAR(m->func_globals);
  11611. Py_CLEAR(m->func_code);
  11612. #if !CYTHON_COMPILING_IN_LIMITED_API
  11613. #if PY_VERSION_HEX < 0x030900B1
  11614. Py_CLEAR(__Pyx_CyFunction_GetClassObj(m));
  11615. #else
  11616. {
  11617. PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class;
  11618. ((PyCMethodObject *) (m))->mm_class = NULL;
  11619. Py_XDECREF(cls);
  11620. }
  11621. #endif
  11622. #endif
  11623. Py_CLEAR(m->defaults_tuple);
  11624. Py_CLEAR(m->defaults_kwdict);
  11625. Py_CLEAR(m->func_annotations);
  11626. Py_CLEAR(m->func_is_coroutine);
  11627. Py_CLEAR(m->defaults);
  11628. return 0;
  11629. }
  11630. static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
  11631. {
  11632. if (__Pyx_CyFunction_weakreflist(m) != NULL)
  11633. PyObject_ClearWeakRefs((PyObject *) m);
  11634. __Pyx_CyFunction_clear(m);
  11635. __Pyx_PyHeapTypeObject_GC_Del(m);
  11636. }
  11637. static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
  11638. {
  11639. PyObject_GC_UnTrack(m);
  11640. __Pyx__CyFunction_dealloc(m);
  11641. }
  11642. static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
  11643. {
  11644. {
  11645. int e = __Pyx_call_type_traverse((PyObject*)m, 1, visit, arg);
  11646. if (e) return e;
  11647. }
  11648. Py_VISIT(m->func_closure);
  11649. #if CYTHON_COMPILING_IN_LIMITED_API
  11650. Py_VISIT(m->func);
  11651. #else
  11652. Py_VISIT(((PyCFunctionObject*)m)->m_module);
  11653. #endif
  11654. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  11655. Py_VISIT(m->func_dict);
  11656. #else
  11657. {
  11658. int e =
  11659. #if PY_VERSION_HEX < 0x030d0000
  11660. _PyObject_VisitManagedDict
  11661. #else
  11662. PyObject_VisitManagedDict
  11663. #endif
  11664. ((PyObject*)m, visit, arg);
  11665. if (e != 0) return e;
  11666. }
  11667. #endif
  11668. __Pyx_VISIT_CONST(m->func_name);
  11669. __Pyx_VISIT_CONST(m->func_qualname);
  11670. Py_VISIT(m->func_doc);
  11671. Py_VISIT(m->func_globals);
  11672. __Pyx_VISIT_CONST(m->func_code);
  11673. #if !CYTHON_COMPILING_IN_LIMITED_API
  11674. Py_VISIT(__Pyx_CyFunction_GetClassObj(m));
  11675. #endif
  11676. Py_VISIT(m->defaults_tuple);
  11677. Py_VISIT(m->defaults_kwdict);
  11678. Py_VISIT(m->func_is_coroutine);
  11679. Py_VISIT(m->defaults);
  11680. return 0;
  11681. }
  11682. static PyObject*
  11683. __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
  11684. {
  11685. PyObject *repr;
  11686. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11687. repr = PyUnicode_FromFormat("<cyfunction %U at %p>",
  11688. op->func_qualname, (void *)op);
  11689. __Pyx_END_CRITICAL_SECTION();
  11690. return repr;
  11691. }
  11692. static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
  11693. #if CYTHON_COMPILING_IN_LIMITED_API
  11694. PyObject *f = ((__pyx_CyFunctionObject*)func)->func;
  11695. PyCFunction meth;
  11696. int flags;
  11697. meth = PyCFunction_GetFunction(f);
  11698. if (unlikely(!meth)) return NULL;
  11699. flags = PyCFunction_GetFlags(f);
  11700. if (unlikely(flags < 0)) return NULL;
  11701. #else
  11702. PyCFunctionObject* f = (PyCFunctionObject*)func;
  11703. PyCFunction meth = f->m_ml->ml_meth;
  11704. int flags = f->m_ml->ml_flags;
  11705. #endif
  11706. Py_ssize_t size;
  11707. switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
  11708. case METH_VARARGS:
  11709. if (likely(kw == NULL || PyDict_Size(kw) == 0))
  11710. return (*meth)(self, arg);
  11711. break;
  11712. case METH_VARARGS | METH_KEYWORDS:
  11713. return (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, arg, kw);
  11714. case METH_NOARGS:
  11715. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  11716. #if CYTHON_ASSUME_SAFE_SIZE
  11717. size = PyTuple_GET_SIZE(arg);
  11718. #else
  11719. size = PyTuple_Size(arg);
  11720. if (unlikely(size < 0)) return NULL;
  11721. #endif
  11722. if (likely(size == 0))
  11723. return (*meth)(self, NULL);
  11724. __Pyx_CyFunction_raise_argument_count_error(
  11725. (__pyx_CyFunctionObject*)func,
  11726. "takes no arguments", size);
  11727. return NULL;
  11728. }
  11729. break;
  11730. case METH_O:
  11731. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  11732. #if CYTHON_ASSUME_SAFE_SIZE
  11733. size = PyTuple_GET_SIZE(arg);
  11734. #else
  11735. size = PyTuple_Size(arg);
  11736. if (unlikely(size < 0)) return NULL;
  11737. #endif
  11738. if (likely(size == 1)) {
  11739. PyObject *result, *arg0;
  11740. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  11741. arg0 = PyTuple_GET_ITEM(arg, 0);
  11742. #else
  11743. arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
  11744. #endif
  11745. result = (*meth)(self, arg0);
  11746. #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
  11747. Py_DECREF(arg0);
  11748. #endif
  11749. return result;
  11750. }
  11751. __Pyx_CyFunction_raise_argument_count_error(
  11752. (__pyx_CyFunctionObject*)func,
  11753. "takes exactly one argument", size);
  11754. return NULL;
  11755. }
  11756. break;
  11757. default:
  11758. PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
  11759. return NULL;
  11760. }
  11761. __Pyx_CyFunction_raise_type_error(
  11762. (__pyx_CyFunctionObject*)func, "takes no keyword arguments");
  11763. return NULL;
  11764. }
  11765. static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  11766. PyObject *self, *result;
  11767. #if CYTHON_COMPILING_IN_LIMITED_API
  11768. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func);
  11769. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  11770. #else
  11771. self = ((PyCFunctionObject*)func)->m_self;
  11772. #endif
  11773. result = __Pyx_CyFunction_CallMethod(func, self, arg, kw);
  11774. return result;
  11775. }
  11776. static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
  11777. PyObject *result;
  11778. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
  11779. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  11780. __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);
  11781. if (vc) {
  11782. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  11783. return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw);
  11784. #else
  11785. (void) &__Pyx_PyVectorcall_FastCallDict;
  11786. return PyVectorcall_Call(func, args, kw);
  11787. #endif
  11788. }
  11789. #endif
  11790. if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
  11791. Py_ssize_t argc;
  11792. PyObject *new_args;
  11793. PyObject *self;
  11794. #if CYTHON_ASSUME_SAFE_SIZE
  11795. argc = PyTuple_GET_SIZE(args);
  11796. #else
  11797. argc = PyTuple_Size(args);
  11798. if (unlikely(argc < 0)) return NULL;
  11799. #endif
  11800. new_args = PyTuple_GetSlice(args, 1, argc);
  11801. if (unlikely(!new_args))
  11802. return NULL;
  11803. self = PyTuple_GetItem(args, 0);
  11804. if (unlikely(!self)) {
  11805. Py_DECREF(new_args);
  11806. PyErr_Format(PyExc_TypeError,
  11807. "unbound method %.200S() needs an argument",
  11808. cyfunc->func_qualname);
  11809. return NULL;
  11810. }
  11811. result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
  11812. Py_DECREF(new_args);
  11813. } else {
  11814. result = __Pyx_CyFunction_Call(func, args, kw);
  11815. }
  11816. return result;
  11817. }
  11818. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  11819. static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames)
  11820. {
  11821. int ret = 0;
  11822. if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
  11823. if (unlikely(nargs < 1)) {
  11824. __Pyx_CyFunction_raise_type_error(
  11825. cyfunc, "needs an argument");
  11826. return -1;
  11827. }
  11828. ret = 1;
  11829. }
  11830. if (unlikely(kwnames) && unlikely(__Pyx_PyTuple_GET_SIZE(kwnames))) {
  11831. __Pyx_CyFunction_raise_type_error(
  11832. cyfunc, "takes no keyword arguments");
  11833. return -1;
  11834. }
  11835. return ret;
  11836. }
  11837. static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  11838. {
  11839. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  11840. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  11841. PyObject *self;
  11842. #if CYTHON_COMPILING_IN_LIMITED_API
  11843. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  11844. if (unlikely(!meth)) return NULL;
  11845. #else
  11846. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  11847. #endif
  11848. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
  11849. case 1:
  11850. self = args[0];
  11851. args += 1;
  11852. nargs -= 1;
  11853. break;
  11854. case 0:
  11855. #if CYTHON_COMPILING_IN_LIMITED_API
  11856. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  11857. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  11858. #else
  11859. self = ((PyCFunctionObject*)cyfunc)->m_self;
  11860. #endif
  11861. break;
  11862. default:
  11863. return NULL;
  11864. }
  11865. if (unlikely(nargs != 0)) {
  11866. __Pyx_CyFunction_raise_argument_count_error(
  11867. cyfunc, "takes no arguments", nargs);
  11868. return NULL;
  11869. }
  11870. return meth(self, NULL);
  11871. }
  11872. static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  11873. {
  11874. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  11875. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  11876. PyObject *self;
  11877. #if CYTHON_COMPILING_IN_LIMITED_API
  11878. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  11879. if (unlikely(!meth)) return NULL;
  11880. #else
  11881. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  11882. #endif
  11883. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
  11884. case 1:
  11885. self = args[0];
  11886. args += 1;
  11887. nargs -= 1;
  11888. break;
  11889. case 0:
  11890. #if CYTHON_COMPILING_IN_LIMITED_API
  11891. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  11892. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  11893. #else
  11894. self = ((PyCFunctionObject*)cyfunc)->m_self;
  11895. #endif
  11896. break;
  11897. default:
  11898. return NULL;
  11899. }
  11900. if (unlikely(nargs != 1)) {
  11901. __Pyx_CyFunction_raise_argument_count_error(
  11902. cyfunc, "takes exactly one argument", nargs);
  11903. return NULL;
  11904. }
  11905. return meth(self, args[0]);
  11906. }
  11907. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  11908. {
  11909. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  11910. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  11911. PyObject *self;
  11912. #if CYTHON_COMPILING_IN_LIMITED_API
  11913. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  11914. if (unlikely(!meth)) return NULL;
  11915. #else
  11916. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  11917. #endif
  11918. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
  11919. case 1:
  11920. self = args[0];
  11921. args += 1;
  11922. nargs -= 1;
  11923. break;
  11924. case 0:
  11925. #if CYTHON_COMPILING_IN_LIMITED_API
  11926. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  11927. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  11928. #else
  11929. self = ((PyCFunctionObject*)cyfunc)->m_self;
  11930. #endif
  11931. break;
  11932. default:
  11933. return NULL;
  11934. }
  11935. return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))meth)(self, args, nargs, kwnames);
  11936. }
  11937. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  11938. {
  11939. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  11940. PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc);
  11941. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  11942. PyObject *self;
  11943. #if CYTHON_COMPILING_IN_LIMITED_API
  11944. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  11945. if (unlikely(!meth)) return NULL;
  11946. #else
  11947. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  11948. #endif
  11949. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
  11950. case 1:
  11951. self = args[0];
  11952. args += 1;
  11953. nargs -= 1;
  11954. break;
  11955. case 0:
  11956. #if CYTHON_COMPILING_IN_LIMITED_API
  11957. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  11958. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  11959. #else
  11960. self = ((PyCFunctionObject*)cyfunc)->m_self;
  11961. #endif
  11962. break;
  11963. default:
  11964. return NULL;
  11965. }
  11966. #if PY_VERSION_HEX < 0x030e00A6
  11967. size_t nargs_value = (size_t) nargs;
  11968. #else
  11969. Py_ssize_t nargs_value = nargs;
  11970. #endif
  11971. return ((__Pyx_PyCMethod)(void(*)(void))meth)(self, cls, args, nargs_value, kwnames);
  11972. }
  11973. #endif
  11974. static PyType_Slot __pyx_CyFunctionType_slots[] = {
  11975. {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc},
  11976. {Py_tp_repr, (void *)__Pyx_CyFunction_repr},
  11977. {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod},
  11978. {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse},
  11979. {Py_tp_clear, (void *)__Pyx_CyFunction_clear},
  11980. {Py_tp_methods, (void *)__pyx_CyFunction_methods},
  11981. {Py_tp_members, (void *)__pyx_CyFunction_members},
  11982. {Py_tp_getset, (void *)__pyx_CyFunction_getsets},
  11983. {Py_tp_descr_get, (void *)__Pyx_PyMethod_New},
  11984. {0, 0},
  11985. };
  11986. static PyType_Spec __pyx_CyFunctionType_spec = {
  11987. __PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
  11988. sizeof(__pyx_CyFunctionObject),
  11989. 0,
  11990. #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR
  11991. Py_TPFLAGS_METHOD_DESCRIPTOR |
  11992. #endif
  11993. #if CYTHON_METH_FASTCALL
  11994. #if defined(Py_TPFLAGS_HAVE_VECTORCALL)
  11995. Py_TPFLAGS_HAVE_VECTORCALL |
  11996. #elif defined(_Py_TPFLAGS_HAVE_VECTORCALL)
  11997. _Py_TPFLAGS_HAVE_VECTORCALL |
  11998. #endif
  11999. #endif // CYTHON_METH_FASTCALL
  12000. #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
  12001. Py_TPFLAGS_MANAGED_DICT |
  12002. #endif
  12003. Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
  12004. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
  12005. __pyx_CyFunctionType_slots
  12006. };
  12007. static int __pyx_CyFunction_init(PyObject *module) {
  12008. __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
  12009. mstate->__pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec(
  12010. mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_CyFunctionType_spec, NULL);
  12011. if (unlikely(mstate->__pyx_CyFunctionType == NULL)) {
  12012. return -1;
  12013. }
  12014. return 0;
  12015. }
  12016. static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) {
  12017. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12018. m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type);
  12019. if (unlikely(!m->defaults))
  12020. return NULL;
  12021. return m->defaults;
  12022. }
  12023. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
  12024. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12025. m->defaults_tuple = tuple;
  12026. Py_INCREF(tuple);
  12027. }
  12028. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
  12029. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12030. m->defaults_kwdict = dict;
  12031. Py_INCREF(dict);
  12032. }
  12033. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
  12034. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12035. m->func_annotations = dict;
  12036. Py_INCREF(dict);
  12037. }
  12038. /* CythonFunction */
  12039. static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
  12040. PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  12041. PyObject *op = __Pyx_CyFunction_Init(
  12042. PyObject_GC_New(__pyx_CyFunctionObject, __pyx_mstate_global->__pyx_CyFunctionType),
  12043. ml, flags, qualname, closure, module, globals, code
  12044. );
  12045. if (likely(op)) {
  12046. PyObject_GC_Track(op);
  12047. }
  12048. return op;
  12049. }
  12050. /* CLineInTraceback (used by AddTraceback) */
  12051. #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  12052. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  12053. #define __Pyx_PyProbablyModule_GetDict(o) __Pyx_XNewRef(PyModule_GetDict(o))
  12054. #elif !CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12055. #define __Pyx_PyProbablyModule_GetDict(o) PyObject_GenericGetDict(o, NULL);
  12056. #else
  12057. PyObject* __Pyx_PyProbablyModule_GetDict(PyObject *o) {
  12058. PyObject **dict_ptr = _PyObject_GetDictPtr(o);
  12059. return dict_ptr ? __Pyx_XNewRef(*dict_ptr) : NULL;
  12060. }
  12061. #endif
  12062. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
  12063. PyObject *use_cline = NULL;
  12064. PyObject *ptype, *pvalue, *ptraceback;
  12065. PyObject *cython_runtime_dict;
  12066. CYTHON_MAYBE_UNUSED_VAR(tstate);
  12067. if (unlikely(!__pyx_mstate_global->__pyx_cython_runtime)) {
  12068. return c_line;
  12069. }
  12070. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  12071. cython_runtime_dict = __Pyx_PyProbablyModule_GetDict(__pyx_mstate_global->__pyx_cython_runtime);
  12072. if (likely(cython_runtime_dict)) {
  12073. __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
  12074. use_cline, cython_runtime_dict,
  12075. __Pyx_PyDict_SetDefault(cython_runtime_dict, __pyx_mstate_global->__pyx_n_u_cline_in_traceback, Py_False))
  12076. }
  12077. if (use_cline == NULL || use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
  12078. c_line = 0;
  12079. }
  12080. Py_XDECREF(use_cline);
  12081. Py_XDECREF(cython_runtime_dict);
  12082. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  12083. return c_line;
  12084. }
  12085. #endif
  12086. /* CodeObjectCache (used by AddTraceback) */
  12087. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  12088. int start = 0, mid = 0, end = count - 1;
  12089. if (end >= 0 && code_line > entries[end].code_line) {
  12090. return count;
  12091. }
  12092. while (start < end) {
  12093. mid = start + (end - start) / 2;
  12094. if (code_line < entries[mid].code_line) {
  12095. end = mid;
  12096. } else if (code_line > entries[mid].code_line) {
  12097. start = mid + 1;
  12098. } else {
  12099. return mid;
  12100. }
  12101. }
  12102. if (code_line <= entries[mid].code_line) {
  12103. return mid;
  12104. } else {
  12105. return mid + 1;
  12106. }
  12107. }
  12108. static __Pyx_CachedCodeObjectType *__pyx__find_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line) {
  12109. __Pyx_CachedCodeObjectType* code_object;
  12110. int pos;
  12111. if (unlikely(!code_line) || unlikely(!code_cache->entries)) {
  12112. return NULL;
  12113. }
  12114. pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
  12115. if (unlikely(pos >= code_cache->count) || unlikely(code_cache->entries[pos].code_line != code_line)) {
  12116. return NULL;
  12117. }
  12118. code_object = code_cache->entries[pos].code_object;
  12119. Py_INCREF(code_object);
  12120. return code_object;
  12121. }
  12122. static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line) {
  12123. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
  12124. (void)__pyx__find_code_object;
  12125. return NULL; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just miss.
  12126. #else
  12127. struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache;
  12128. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12129. __pyx_nonatomic_int_type old_count = __pyx_atomic_incr_acq_rel(&code_cache->accessor_count);
  12130. if (old_count < 0) {
  12131. __pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
  12132. return NULL;
  12133. }
  12134. #endif
  12135. __Pyx_CachedCodeObjectType *result = __pyx__find_code_object(code_cache, code_line);
  12136. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12137. __pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
  12138. #endif
  12139. return result;
  12140. #endif
  12141. }
  12142. static void __pyx__insert_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line, __Pyx_CachedCodeObjectType* code_object)
  12143. {
  12144. int pos, i;
  12145. __Pyx_CodeObjectCacheEntry* entries = code_cache->entries;
  12146. if (unlikely(!code_line)) {
  12147. return;
  12148. }
  12149. if (unlikely(!entries)) {
  12150. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  12151. if (likely(entries)) {
  12152. code_cache->entries = entries;
  12153. code_cache->max_count = 64;
  12154. code_cache->count = 1;
  12155. entries[0].code_line = code_line;
  12156. entries[0].code_object = code_object;
  12157. Py_INCREF(code_object);
  12158. }
  12159. return;
  12160. }
  12161. pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
  12162. if ((pos < code_cache->count) && unlikely(code_cache->entries[pos].code_line == code_line)) {
  12163. __Pyx_CachedCodeObjectType* tmp = entries[pos].code_object;
  12164. entries[pos].code_object = code_object;
  12165. Py_INCREF(code_object);
  12166. Py_DECREF(tmp);
  12167. return;
  12168. }
  12169. if (code_cache->count == code_cache->max_count) {
  12170. int new_max = code_cache->max_count + 64;
  12171. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  12172. code_cache->entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
  12173. if (unlikely(!entries)) {
  12174. return;
  12175. }
  12176. code_cache->entries = entries;
  12177. code_cache->max_count = new_max;
  12178. }
  12179. for (i=code_cache->count; i>pos; i--) {
  12180. entries[i] = entries[i-1];
  12181. }
  12182. entries[pos].code_line = code_line;
  12183. entries[pos].code_object = code_object;
  12184. code_cache->count++;
  12185. Py_INCREF(code_object);
  12186. }
  12187. static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object) {
  12188. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
  12189. (void)__pyx__insert_code_object;
  12190. return; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just fail.
  12191. #else
  12192. struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache;
  12193. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12194. __pyx_nonatomic_int_type expected = 0;
  12195. if (!__pyx_atomic_int_cmp_exchange(&code_cache->accessor_count, &expected, INT_MIN)) {
  12196. return;
  12197. }
  12198. #endif
  12199. __pyx__insert_code_object(code_cache, code_line, code_object);
  12200. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12201. __pyx_atomic_sub(&code_cache->accessor_count, INT_MIN);
  12202. #endif
  12203. #endif
  12204. }
  12205. /* AddTraceback */
  12206. #include "compile.h"
  12207. #include "frameobject.h"
  12208. #include "traceback.h"
  12209. #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
  12210. #ifndef Py_BUILD_CORE
  12211. #define Py_BUILD_CORE 1
  12212. #endif
  12213. #include "internal/pycore_frame.h"
  12214. #endif
  12215. #if CYTHON_COMPILING_IN_LIMITED_API
  12216. static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict,
  12217. PyObject *firstlineno, PyObject *name) {
  12218. PyObject *replace = NULL;
  12219. if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL;
  12220. if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL;
  12221. replace = PyObject_GetAttrString(code, "replace");
  12222. if (likely(replace)) {
  12223. PyObject *result = PyObject_Call(replace, __pyx_mstate_global->__pyx_empty_tuple, scratch_dict);
  12224. Py_DECREF(replace);
  12225. return result;
  12226. }
  12227. PyErr_Clear();
  12228. return NULL;
  12229. }
  12230. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  12231. int py_line, const char *filename) {
  12232. PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL;
  12233. PyObject *replace = NULL, *getframe = NULL, *frame = NULL;
  12234. PyObject *exc_type, *exc_value, *exc_traceback;
  12235. int success = 0;
  12236. if (c_line) {
  12237. c_line = __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line);
  12238. }
  12239. PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
  12240. code_object = __pyx_find_code_object(c_line ? -c_line : py_line);
  12241. if (!code_object) {
  12242. code_object = Py_CompileString("_getframe()", filename, Py_eval_input);
  12243. if (unlikely(!code_object)) goto bad;
  12244. py_py_line = PyLong_FromLong(py_line);
  12245. if (unlikely(!py_py_line)) goto bad;
  12246. if (c_line) {
  12247. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  12248. } else {
  12249. py_funcname = PyUnicode_FromString(funcname);
  12250. }
  12251. if (unlikely(!py_funcname)) goto bad;
  12252. dict = PyDict_New();
  12253. if (unlikely(!dict)) goto bad;
  12254. {
  12255. PyObject *old_code_object = code_object;
  12256. code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname);
  12257. Py_DECREF(old_code_object);
  12258. }
  12259. if (unlikely(!code_object)) goto bad;
  12260. __pyx_insert_code_object(c_line ? -c_line : py_line, code_object);
  12261. } else {
  12262. dict = PyDict_New();
  12263. }
  12264. getframe = PySys_GetObject("_getframe");
  12265. if (unlikely(!getframe)) goto bad;
  12266. if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad;
  12267. frame = PyEval_EvalCode(code_object, dict, dict);
  12268. if (unlikely(!frame) || frame == Py_None) goto bad;
  12269. success = 1;
  12270. bad:
  12271. PyErr_Restore(exc_type, exc_value, exc_traceback);
  12272. Py_XDECREF(code_object);
  12273. Py_XDECREF(py_py_line);
  12274. Py_XDECREF(py_funcname);
  12275. Py_XDECREF(dict);
  12276. Py_XDECREF(replace);
  12277. if (success) {
  12278. PyTraceBack_Here(
  12279. (struct _frame*)frame);
  12280. }
  12281. Py_XDECREF(frame);
  12282. }
  12283. #else
  12284. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  12285. const char *funcname, int c_line,
  12286. int py_line, const char *filename) {
  12287. PyCodeObject *py_code = NULL;
  12288. PyObject *py_funcname = NULL;
  12289. if (c_line) {
  12290. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  12291. if (!py_funcname) goto bad;
  12292. funcname = PyUnicode_AsUTF8(py_funcname);
  12293. if (!funcname) goto bad;
  12294. }
  12295. py_code = PyCode_NewEmpty(filename, funcname, py_line);
  12296. Py_XDECREF(py_funcname);
  12297. return py_code;
  12298. bad:
  12299. Py_XDECREF(py_funcname);
  12300. return NULL;
  12301. }
  12302. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  12303. int py_line, const char *filename) {
  12304. PyCodeObject *py_code = 0;
  12305. PyFrameObject *py_frame = 0;
  12306. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  12307. PyObject *ptype, *pvalue, *ptraceback;
  12308. if (c_line) {
  12309. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  12310. }
  12311. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  12312. if (!py_code) {
  12313. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  12314. py_code = __Pyx_CreateCodeObjectForTraceback(
  12315. funcname, c_line, py_line, filename);
  12316. if (!py_code) {
  12317. /* If the code object creation fails, then we should clear the
  12318. fetched exception references and propagate the new exception */
  12319. Py_XDECREF(ptype);
  12320. Py_XDECREF(pvalue);
  12321. Py_XDECREF(ptraceback);
  12322. goto bad;
  12323. }
  12324. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  12325. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  12326. }
  12327. py_frame = PyFrame_New(
  12328. tstate, /*PyThreadState *tstate,*/
  12329. py_code, /*PyCodeObject *code,*/
  12330. __pyx_mstate_global->__pyx_d, /*PyObject *globals,*/
  12331. 0 /*PyObject *locals*/
  12332. );
  12333. if (!py_frame) goto bad;
  12334. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  12335. PyTraceBack_Here(py_frame);
  12336. bad:
  12337. Py_XDECREF(py_code);
  12338. Py_XDECREF(py_frame);
  12339. }
  12340. #endif
  12341. /* Declarations */
  12342. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  12343. #ifdef __cplusplus
  12344. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  12345. return ::std::complex< double >(x, y);
  12346. }
  12347. #else
  12348. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  12349. return x + y*(__pyx_t_double_complex)_Complex_I;
  12350. }
  12351. #endif
  12352. #else
  12353. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  12354. __pyx_t_double_complex z;
  12355. z.real = x;
  12356. z.imag = y;
  12357. return z;
  12358. }
  12359. #endif
  12360. /* Arithmetic */
  12361. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  12362. #else
  12363. static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12364. return (a.real == b.real) && (a.imag == b.imag);
  12365. }
  12366. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12367. __pyx_t_double_complex z;
  12368. z.real = a.real + b.real;
  12369. z.imag = a.imag + b.imag;
  12370. return z;
  12371. }
  12372. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12373. __pyx_t_double_complex z;
  12374. z.real = a.real - b.real;
  12375. z.imag = a.imag - b.imag;
  12376. return z;
  12377. }
  12378. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12379. __pyx_t_double_complex z;
  12380. z.real = a.real * b.real - a.imag * b.imag;
  12381. z.imag = a.real * b.imag + a.imag * b.real;
  12382. return z;
  12383. }
  12384. #if 1
  12385. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12386. if (b.imag == 0) {
  12387. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
  12388. } else if (fabs(b.real) >= fabs(b.imag)) {
  12389. if (b.real == 0 && b.imag == 0) {
  12390. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
  12391. } else {
  12392. double r = b.imag / b.real;
  12393. double s = (double)(1.0) / (b.real + b.imag * r);
  12394. return __pyx_t_double_complex_from_parts(
  12395. (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
  12396. }
  12397. } else {
  12398. double r = b.real / b.imag;
  12399. double s = (double)(1.0) / (b.imag + b.real * r);
  12400. return __pyx_t_double_complex_from_parts(
  12401. (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
  12402. }
  12403. }
  12404. #else
  12405. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12406. if (b.imag == 0) {
  12407. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
  12408. } else {
  12409. double denom = b.real * b.real + b.imag * b.imag;
  12410. return __pyx_t_double_complex_from_parts(
  12411. (a.real * b.real + a.imag * b.imag) / denom,
  12412. (a.imag * b.real - a.real * b.imag) / denom);
  12413. }
  12414. }
  12415. #endif
  12416. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
  12417. __pyx_t_double_complex z;
  12418. z.real = -a.real;
  12419. z.imag = -a.imag;
  12420. return z;
  12421. }
  12422. static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
  12423. return (a.real == 0) && (a.imag == 0);
  12424. }
  12425. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
  12426. __pyx_t_double_complex z;
  12427. z.real = a.real;
  12428. z.imag = -a.imag;
  12429. return z;
  12430. }
  12431. #if 1
  12432. static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
  12433. #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
  12434. return sqrt(z.real*z.real + z.imag*z.imag);
  12435. #else
  12436. return hypot(z.real, z.imag);
  12437. #endif
  12438. }
  12439. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12440. __pyx_t_double_complex z;
  12441. double r, lnr, theta, z_r, z_theta;
  12442. if (b.imag == 0 && b.real == (int)b.real) {
  12443. if (b.real < 0) {
  12444. double denom = a.real * a.real + a.imag * a.imag;
  12445. a.real = a.real / denom;
  12446. a.imag = -a.imag / denom;
  12447. b.real = -b.real;
  12448. }
  12449. switch ((int)b.real) {
  12450. case 0:
  12451. z.real = 1;
  12452. z.imag = 0;
  12453. return z;
  12454. case 1:
  12455. return a;
  12456. case 2:
  12457. return __Pyx_c_prod_double(a, a);
  12458. case 3:
  12459. z = __Pyx_c_prod_double(a, a);
  12460. return __Pyx_c_prod_double(z, a);
  12461. case 4:
  12462. z = __Pyx_c_prod_double(a, a);
  12463. return __Pyx_c_prod_double(z, z);
  12464. }
  12465. }
  12466. if (a.imag == 0) {
  12467. if (a.real == 0) {
  12468. return a;
  12469. } else if ((b.imag == 0) && (a.real >= 0)) {
  12470. z.real = pow(a.real, b.real);
  12471. z.imag = 0;
  12472. return z;
  12473. } else if (a.real > 0) {
  12474. r = a.real;
  12475. theta = 0;
  12476. } else {
  12477. r = -a.real;
  12478. theta = atan2(0.0, -1.0);
  12479. }
  12480. } else {
  12481. r = __Pyx_c_abs_double(a);
  12482. theta = atan2(a.imag, a.real);
  12483. }
  12484. lnr = log(r);
  12485. z_r = exp(lnr * b.real - theta * b.imag);
  12486. z_theta = theta * b.real + lnr * b.imag;
  12487. z.real = z_r * cos(z_theta);
  12488. z.imag = z_r * sin(z_theta);
  12489. return z;
  12490. }
  12491. #endif
  12492. #endif
  12493. /* FromPy */
  12494. static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject* o) {
  12495. #if CYTHON_COMPILING_IN_LIMITED_API
  12496. double real=-1.0, imag=-1.0;
  12497. real = PyComplex_RealAsDouble(o);
  12498. if (unlikely(real == -1.0 && PyErr_Occurred())) goto end;
  12499. imag = PyComplex_ImagAsDouble(o);
  12500. end:
  12501. return __pyx_t_double_complex_from_parts(
  12502. (double)real, (double)imag
  12503. );
  12504. #else
  12505. Py_complex cval;
  12506. #if !CYTHON_COMPILING_IN_PYPY && !CYTHON_COMPILING_IN_GRAAL
  12507. if (PyComplex_CheckExact(o))
  12508. cval = ((PyComplexObject *)o)->cval;
  12509. else
  12510. #endif
  12511. cval = PyComplex_AsCComplex(o);
  12512. return __pyx_t_double_complex_from_parts(
  12513. (double)cval.real,
  12514. (double)cval.imag);
  12515. #endif
  12516. }
  12517. /* CIntFromPyVerify */
  12518. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  12519. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  12520. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  12521. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  12522. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  12523. {\
  12524. func_type value = func_value;\
  12525. if (sizeof(target_type) < sizeof(func_type)) {\
  12526. if (unlikely(value != (func_type) (target_type) value)) {\
  12527. func_type zero = 0;\
  12528. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  12529. return (target_type) -1;\
  12530. if (is_unsigned && unlikely(value < zero))\
  12531. goto raise_neg_overflow;\
  12532. else\
  12533. goto raise_overflow;\
  12534. }\
  12535. }\
  12536. return (target_type) value;\
  12537. }
  12538. /* CIntFromPy */
  12539. static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *x) {
  12540. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12541. #pragma GCC diagnostic push
  12542. #pragma GCC diagnostic ignored "-Wconversion"
  12543. #endif
  12544. const int neg_one = (int) -1, const_zero = (int) 0;
  12545. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12546. #pragma GCC diagnostic pop
  12547. #endif
  12548. const int is_unsigned = neg_one > const_zero;
  12549. if (unlikely(!PyLong_Check(x))) {
  12550. int val;
  12551. PyObject *tmp = __Pyx_PyNumber_Long(x);
  12552. if (!tmp) return (int) -1;
  12553. val = __Pyx_PyLong_As_int(tmp);
  12554. Py_DECREF(tmp);
  12555. return val;
  12556. }
  12557. if (is_unsigned) {
  12558. #if CYTHON_USE_PYLONG_INTERNALS
  12559. if (unlikely(__Pyx_PyLong_IsNeg(x))) {
  12560. goto raise_neg_overflow;
  12561. } else if (__Pyx_PyLong_IsCompact(x)) {
  12562. __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
  12563. } else {
  12564. const digit* digits = __Pyx_PyLong_Digits(x);
  12565. assert(__Pyx_PyLong_DigitCount(x) > 1);
  12566. switch (__Pyx_PyLong_DigitCount(x)) {
  12567. case 2:
  12568. if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
  12569. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  12570. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12571. } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) {
  12572. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  12573. }
  12574. }
  12575. break;
  12576. case 3:
  12577. if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
  12578. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  12579. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12580. } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) {
  12581. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  12582. }
  12583. }
  12584. break;
  12585. case 4:
  12586. if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
  12587. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  12588. __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])))
  12589. } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) {
  12590. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  12591. }
  12592. }
  12593. break;
  12594. }
  12595. }
  12596. #endif
  12597. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
  12598. if (unlikely(Py_SIZE(x) < 0)) {
  12599. goto raise_neg_overflow;
  12600. }
  12601. #else
  12602. {
  12603. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  12604. if (unlikely(result < 0))
  12605. return (int) -1;
  12606. if (unlikely(result == 1))
  12607. goto raise_neg_overflow;
  12608. }
  12609. #endif
  12610. if ((sizeof(int) <= sizeof(unsigned long))) {
  12611. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  12612. } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) {
  12613. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  12614. }
  12615. } else {
  12616. #if CYTHON_USE_PYLONG_INTERNALS
  12617. if (__Pyx_PyLong_IsCompact(x)) {
  12618. __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
  12619. } else {
  12620. const digit* digits = __Pyx_PyLong_Digits(x);
  12621. assert(__Pyx_PyLong_DigitCount(x) > 1);
  12622. switch (__Pyx_PyLong_SignedDigitCount(x)) {
  12623. case -2:
  12624. if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) {
  12625. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  12626. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12627. } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
  12628. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12629. }
  12630. }
  12631. break;
  12632. case 2:
  12633. if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
  12634. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  12635. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12636. } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
  12637. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12638. }
  12639. }
  12640. break;
  12641. case -3:
  12642. if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
  12643. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  12644. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12645. } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
  12646. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12647. }
  12648. }
  12649. break;
  12650. case 3:
  12651. if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
  12652. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  12653. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12654. } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
  12655. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12656. }
  12657. }
  12658. break;
  12659. case -4:
  12660. if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
  12661. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  12662. __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])))
  12663. } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
  12664. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12665. }
  12666. }
  12667. break;
  12668. case 4:
  12669. if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
  12670. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  12671. __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])))
  12672. } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
  12673. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12674. }
  12675. }
  12676. break;
  12677. }
  12678. }
  12679. #endif
  12680. if ((sizeof(int) <= sizeof(long))) {
  12681. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  12682. } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) {
  12683. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  12684. }
  12685. }
  12686. {
  12687. int val;
  12688. int ret = -1;
  12689. #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
  12690. Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
  12691. x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
  12692. if (unlikely(bytes_copied == -1)) {
  12693. } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
  12694. goto raise_overflow;
  12695. } else {
  12696. ret = 0;
  12697. }
  12698. #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
  12699. int one = 1; int is_little = (int)*(unsigned char *)&one;
  12700. unsigned char *bytes = (unsigned char *)&val;
  12701. ret = _PyLong_AsByteArray((PyLongObject *)x,
  12702. bytes, sizeof(val),
  12703. is_little, !is_unsigned);
  12704. #else
  12705. PyObject *v;
  12706. PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
  12707. int bits, remaining_bits, is_negative = 0;
  12708. int chunk_size = (sizeof(long) < 8) ? 30 : 62;
  12709. if (likely(PyLong_CheckExact(x))) {
  12710. v = __Pyx_NewRef(x);
  12711. } else {
  12712. v = PyNumber_Long(x);
  12713. if (unlikely(!v)) return (int) -1;
  12714. assert(PyLong_CheckExact(v));
  12715. }
  12716. {
  12717. int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
  12718. if (unlikely(result < 0)) {
  12719. Py_DECREF(v);
  12720. return (int) -1;
  12721. }
  12722. is_negative = result == 1;
  12723. }
  12724. if (is_unsigned && unlikely(is_negative)) {
  12725. Py_DECREF(v);
  12726. goto raise_neg_overflow;
  12727. } else if (is_negative) {
  12728. stepval = PyNumber_Invert(v);
  12729. Py_DECREF(v);
  12730. if (unlikely(!stepval))
  12731. return (int) -1;
  12732. } else {
  12733. stepval = v;
  12734. }
  12735. v = NULL;
  12736. val = (int) 0;
  12737. mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
  12738. shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
  12739. for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
  12740. PyObject *tmp, *digit;
  12741. long idigit;
  12742. digit = PyNumber_And(stepval, mask);
  12743. if (unlikely(!digit)) goto done;
  12744. idigit = PyLong_AsLong(digit);
  12745. Py_DECREF(digit);
  12746. if (unlikely(idigit < 0)) goto done;
  12747. val |= ((int) idigit) << bits;
  12748. tmp = PyNumber_Rshift(stepval, shift);
  12749. if (unlikely(!tmp)) goto done;
  12750. Py_DECREF(stepval); stepval = tmp;
  12751. }
  12752. Py_DECREF(shift); shift = NULL;
  12753. Py_DECREF(mask); mask = NULL;
  12754. {
  12755. long idigit = PyLong_AsLong(stepval);
  12756. if (unlikely(idigit < 0)) goto done;
  12757. remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
  12758. if (unlikely(idigit >= (1L << remaining_bits)))
  12759. goto raise_overflow;
  12760. val |= ((int) idigit) << bits;
  12761. }
  12762. if (!is_unsigned) {
  12763. if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
  12764. goto raise_overflow;
  12765. if (is_negative)
  12766. val = ~val;
  12767. }
  12768. ret = 0;
  12769. done:
  12770. Py_XDECREF(shift);
  12771. Py_XDECREF(mask);
  12772. Py_XDECREF(stepval);
  12773. #endif
  12774. if (unlikely(ret))
  12775. return (int) -1;
  12776. return val;
  12777. }
  12778. raise_overflow:
  12779. PyErr_SetString(PyExc_OverflowError,
  12780. "value too large to convert to int");
  12781. return (int) -1;
  12782. raise_neg_overflow:
  12783. PyErr_SetString(PyExc_OverflowError,
  12784. "can't convert negative value to int");
  12785. return (int) -1;
  12786. }
  12787. /* PyObjectVectorCallKwBuilder (used by CIntToPy) */
  12788. #if CYTHON_VECTORCALL
  12789. static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
  12790. (void)__Pyx_PyObject_FastCallDict;
  12791. if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1;
  12792. Py_INCREF(key);
  12793. args[n] = value;
  12794. return 0;
  12795. }
  12796. CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
  12797. (void)__Pyx_VectorcallBuilder_AddArgStr;
  12798. if (unlikely(!PyUnicode_Check(key))) {
  12799. PyErr_SetString(PyExc_TypeError, "keywords must be strings");
  12800. return -1;
  12801. }
  12802. return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n);
  12803. }
  12804. static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
  12805. PyObject *pyKey = PyUnicode_FromString(key);
  12806. if (!pyKey) return -1;
  12807. return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n);
  12808. }
  12809. #else // CYTHON_VECTORCALL
  12810. CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) {
  12811. if (unlikely(!PyUnicode_Check(key))) {
  12812. PyErr_SetString(PyExc_TypeError, "keywords must be strings");
  12813. return -1;
  12814. }
  12815. return PyDict_SetItem(builder, key, value);
  12816. }
  12817. #endif
  12818. /* CIntToPy */
  12819. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) {
  12820. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12821. #pragma GCC diagnostic push
  12822. #pragma GCC diagnostic ignored "-Wconversion"
  12823. #endif
  12824. const long neg_one = (long) -1, const_zero = (long) 0;
  12825. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12826. #pragma GCC diagnostic pop
  12827. #endif
  12828. const int is_unsigned = neg_one > const_zero;
  12829. if (is_unsigned) {
  12830. if (sizeof(long) < sizeof(long)) {
  12831. return PyLong_FromLong((long) value);
  12832. } else if (sizeof(long) <= sizeof(unsigned long)) {
  12833. return PyLong_FromUnsignedLong((unsigned long) value);
  12834. #if !CYTHON_COMPILING_IN_PYPY
  12835. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  12836. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  12837. #endif
  12838. }
  12839. } else {
  12840. if (sizeof(long) <= sizeof(long)) {
  12841. return PyLong_FromLong((long) value);
  12842. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  12843. return PyLong_FromLongLong((PY_LONG_LONG) value);
  12844. }
  12845. }
  12846. {
  12847. unsigned char *bytes = (unsigned char *)&value;
  12848. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
  12849. if (is_unsigned) {
  12850. return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
  12851. } else {
  12852. return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
  12853. }
  12854. #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
  12855. int one = 1; int little = (int)*(unsigned char *)&one;
  12856. return _PyLong_FromByteArray(bytes, sizeof(long),
  12857. little, !is_unsigned);
  12858. #else
  12859. int one = 1; int little = (int)*(unsigned char *)&one;
  12860. PyObject *from_bytes, *result = NULL, *kwds = NULL;
  12861. PyObject *py_bytes = NULL, *order_str = NULL;
  12862. from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
  12863. if (!from_bytes) return NULL;
  12864. py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long));
  12865. if (!py_bytes) goto limited_bad;
  12866. order_str = PyUnicode_FromString(little ? "little" : "big");
  12867. if (!order_str) goto limited_bad;
  12868. {
  12869. PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str };
  12870. if (!is_unsigned) {
  12871. kwds = __Pyx_MakeVectorcallBuilderKwds(1);
  12872. if (!kwds) goto limited_bad;
  12873. if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad;
  12874. }
  12875. result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds);
  12876. }
  12877. limited_bad:
  12878. Py_XDECREF(kwds);
  12879. Py_XDECREF(order_str);
  12880. Py_XDECREF(py_bytes);
  12881. Py_XDECREF(from_bytes);
  12882. return result;
  12883. #endif
  12884. }
  12885. }
  12886. /* CIntToPy */
  12887. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_int(int value) {
  12888. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12889. #pragma GCC diagnostic push
  12890. #pragma GCC diagnostic ignored "-Wconversion"
  12891. #endif
  12892. const int neg_one = (int) -1, const_zero = (int) 0;
  12893. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12894. #pragma GCC diagnostic pop
  12895. #endif
  12896. const int is_unsigned = neg_one > const_zero;
  12897. if (is_unsigned) {
  12898. if (sizeof(int) < sizeof(long)) {
  12899. return PyLong_FromLong((long) value);
  12900. } else if (sizeof(int) <= sizeof(unsigned long)) {
  12901. return PyLong_FromUnsignedLong((unsigned long) value);
  12902. #if !CYTHON_COMPILING_IN_PYPY
  12903. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  12904. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  12905. #endif
  12906. }
  12907. } else {
  12908. if (sizeof(int) <= sizeof(long)) {
  12909. return PyLong_FromLong((long) value);
  12910. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  12911. return PyLong_FromLongLong((PY_LONG_LONG) value);
  12912. }
  12913. }
  12914. {
  12915. unsigned char *bytes = (unsigned char *)&value;
  12916. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
  12917. if (is_unsigned) {
  12918. return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
  12919. } else {
  12920. return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
  12921. }
  12922. #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
  12923. int one = 1; int little = (int)*(unsigned char *)&one;
  12924. return _PyLong_FromByteArray(bytes, sizeof(int),
  12925. little, !is_unsigned);
  12926. #else
  12927. int one = 1; int little = (int)*(unsigned char *)&one;
  12928. PyObject *from_bytes, *result = NULL, *kwds = NULL;
  12929. PyObject *py_bytes = NULL, *order_str = NULL;
  12930. from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
  12931. if (!from_bytes) return NULL;
  12932. py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(int));
  12933. if (!py_bytes) goto limited_bad;
  12934. order_str = PyUnicode_FromString(little ? "little" : "big");
  12935. if (!order_str) goto limited_bad;
  12936. {
  12937. PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str };
  12938. if (!is_unsigned) {
  12939. kwds = __Pyx_MakeVectorcallBuilderKwds(1);
  12940. if (!kwds) goto limited_bad;
  12941. if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad;
  12942. }
  12943. result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds);
  12944. }
  12945. limited_bad:
  12946. Py_XDECREF(kwds);
  12947. Py_XDECREF(order_str);
  12948. Py_XDECREF(py_bytes);
  12949. Py_XDECREF(from_bytes);
  12950. return result;
  12951. #endif
  12952. }
  12953. }
  12954. /* FormatTypeName */
  12955. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
  12956. static __Pyx_TypeName
  12957. __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp)
  12958. {
  12959. PyObject *module = NULL, *name = NULL, *result = NULL;
  12960. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  12961. name = __Pyx_PyObject_GetAttrStr((PyObject *)tp,
  12962. __pyx_mstate_global->__pyx_n_u_qualname);
  12963. #else
  12964. name = PyType_GetQualName(tp);
  12965. #endif
  12966. if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad;
  12967. module = __Pyx_PyObject_GetAttrStr((PyObject *)tp,
  12968. __pyx_mstate_global->__pyx_n_u_module);
  12969. if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad;
  12970. if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) {
  12971. result = name;
  12972. name = NULL;
  12973. goto done;
  12974. }
  12975. result = PyUnicode_FromFormat("%U.%U", module, name);
  12976. if (unlikely(result == NULL)) goto bad;
  12977. done:
  12978. Py_XDECREF(name);
  12979. Py_XDECREF(module);
  12980. return result;
  12981. bad:
  12982. PyErr_Clear();
  12983. if (name) {
  12984. result = name;
  12985. name = NULL;
  12986. } else {
  12987. result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u__2);
  12988. }
  12989. goto done;
  12990. }
  12991. #endif
  12992. /* CIntFromPy */
  12993. static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *x) {
  12994. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12995. #pragma GCC diagnostic push
  12996. #pragma GCC diagnostic ignored "-Wconversion"
  12997. #endif
  12998. const long neg_one = (long) -1, const_zero = (long) 0;
  12999. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  13000. #pragma GCC diagnostic pop
  13001. #endif
  13002. const int is_unsigned = neg_one > const_zero;
  13003. if (unlikely(!PyLong_Check(x))) {
  13004. long val;
  13005. PyObject *tmp = __Pyx_PyNumber_Long(x);
  13006. if (!tmp) return (long) -1;
  13007. val = __Pyx_PyLong_As_long(tmp);
  13008. Py_DECREF(tmp);
  13009. return val;
  13010. }
  13011. if (is_unsigned) {
  13012. #if CYTHON_USE_PYLONG_INTERNALS
  13013. if (unlikely(__Pyx_PyLong_IsNeg(x))) {
  13014. goto raise_neg_overflow;
  13015. } else if (__Pyx_PyLong_IsCompact(x)) {
  13016. __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
  13017. } else {
  13018. const digit* digits = __Pyx_PyLong_Digits(x);
  13019. assert(__Pyx_PyLong_DigitCount(x) > 1);
  13020. switch (__Pyx_PyLong_DigitCount(x)) {
  13021. case 2:
  13022. if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
  13023. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  13024. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13025. } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) {
  13026. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  13027. }
  13028. }
  13029. break;
  13030. case 3:
  13031. if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
  13032. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  13033. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13034. } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) {
  13035. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  13036. }
  13037. }
  13038. break;
  13039. case 4:
  13040. if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
  13041. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  13042. __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])))
  13043. } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) {
  13044. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  13045. }
  13046. }
  13047. break;
  13048. }
  13049. }
  13050. #endif
  13051. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
  13052. if (unlikely(Py_SIZE(x) < 0)) {
  13053. goto raise_neg_overflow;
  13054. }
  13055. #else
  13056. {
  13057. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  13058. if (unlikely(result < 0))
  13059. return (long) -1;
  13060. if (unlikely(result == 1))
  13061. goto raise_neg_overflow;
  13062. }
  13063. #endif
  13064. if ((sizeof(long) <= sizeof(unsigned long))) {
  13065. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  13066. } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) {
  13067. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  13068. }
  13069. } else {
  13070. #if CYTHON_USE_PYLONG_INTERNALS
  13071. if (__Pyx_PyLong_IsCompact(x)) {
  13072. __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
  13073. } else {
  13074. const digit* digits = __Pyx_PyLong_Digits(x);
  13075. assert(__Pyx_PyLong_DigitCount(x) > 1);
  13076. switch (__Pyx_PyLong_SignedDigitCount(x)) {
  13077. case -2:
  13078. if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) {
  13079. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  13080. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13081. } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
  13082. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13083. }
  13084. }
  13085. break;
  13086. case 2:
  13087. if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
  13088. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  13089. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13090. } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
  13091. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13092. }
  13093. }
  13094. break;
  13095. case -3:
  13096. if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
  13097. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  13098. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13099. } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
  13100. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13101. }
  13102. }
  13103. break;
  13104. case 3:
  13105. if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
  13106. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  13107. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13108. } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
  13109. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13110. }
  13111. }
  13112. break;
  13113. case -4:
  13114. if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
  13115. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  13116. __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])))
  13117. } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
  13118. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13119. }
  13120. }
  13121. break;
  13122. case 4:
  13123. if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
  13124. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  13125. __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])))
  13126. } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
  13127. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13128. }
  13129. }
  13130. break;
  13131. }
  13132. }
  13133. #endif
  13134. if ((sizeof(long) <= sizeof(long))) {
  13135. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  13136. } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) {
  13137. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  13138. }
  13139. }
  13140. {
  13141. long val;
  13142. int ret = -1;
  13143. #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
  13144. Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
  13145. x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
  13146. if (unlikely(bytes_copied == -1)) {
  13147. } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
  13148. goto raise_overflow;
  13149. } else {
  13150. ret = 0;
  13151. }
  13152. #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
  13153. int one = 1; int is_little = (int)*(unsigned char *)&one;
  13154. unsigned char *bytes = (unsigned char *)&val;
  13155. ret = _PyLong_AsByteArray((PyLongObject *)x,
  13156. bytes, sizeof(val),
  13157. is_little, !is_unsigned);
  13158. #else
  13159. PyObject *v;
  13160. PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
  13161. int bits, remaining_bits, is_negative = 0;
  13162. int chunk_size = (sizeof(long) < 8) ? 30 : 62;
  13163. if (likely(PyLong_CheckExact(x))) {
  13164. v = __Pyx_NewRef(x);
  13165. } else {
  13166. v = PyNumber_Long(x);
  13167. if (unlikely(!v)) return (long) -1;
  13168. assert(PyLong_CheckExact(v));
  13169. }
  13170. {
  13171. int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
  13172. if (unlikely(result < 0)) {
  13173. Py_DECREF(v);
  13174. return (long) -1;
  13175. }
  13176. is_negative = result == 1;
  13177. }
  13178. if (is_unsigned && unlikely(is_negative)) {
  13179. Py_DECREF(v);
  13180. goto raise_neg_overflow;
  13181. } else if (is_negative) {
  13182. stepval = PyNumber_Invert(v);
  13183. Py_DECREF(v);
  13184. if (unlikely(!stepval))
  13185. return (long) -1;
  13186. } else {
  13187. stepval = v;
  13188. }
  13189. v = NULL;
  13190. val = (long) 0;
  13191. mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
  13192. shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
  13193. for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
  13194. PyObject *tmp, *digit;
  13195. long idigit;
  13196. digit = PyNumber_And(stepval, mask);
  13197. if (unlikely(!digit)) goto done;
  13198. idigit = PyLong_AsLong(digit);
  13199. Py_DECREF(digit);
  13200. if (unlikely(idigit < 0)) goto done;
  13201. val |= ((long) idigit) << bits;
  13202. tmp = PyNumber_Rshift(stepval, shift);
  13203. if (unlikely(!tmp)) goto done;
  13204. Py_DECREF(stepval); stepval = tmp;
  13205. }
  13206. Py_DECREF(shift); shift = NULL;
  13207. Py_DECREF(mask); mask = NULL;
  13208. {
  13209. long idigit = PyLong_AsLong(stepval);
  13210. if (unlikely(idigit < 0)) goto done;
  13211. remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
  13212. if (unlikely(idigit >= (1L << remaining_bits)))
  13213. goto raise_overflow;
  13214. val |= ((long) idigit) << bits;
  13215. }
  13216. if (!is_unsigned) {
  13217. if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
  13218. goto raise_overflow;
  13219. if (is_negative)
  13220. val = ~val;
  13221. }
  13222. ret = 0;
  13223. done:
  13224. Py_XDECREF(shift);
  13225. Py_XDECREF(mask);
  13226. Py_XDECREF(stepval);
  13227. #endif
  13228. if (unlikely(ret))
  13229. return (long) -1;
  13230. return val;
  13231. }
  13232. raise_overflow:
  13233. PyErr_SetString(PyExc_OverflowError,
  13234. "value too large to convert to long");
  13235. return (long) -1;
  13236. raise_neg_overflow:
  13237. PyErr_SetString(PyExc_OverflowError,
  13238. "can't convert negative value to long");
  13239. return (long) -1;
  13240. }
  13241. /* FastTypeChecks */
  13242. #if CYTHON_COMPILING_IN_CPYTHON
  13243. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  13244. while (a) {
  13245. a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*);
  13246. if (a == b)
  13247. return 1;
  13248. }
  13249. return b == &PyBaseObject_Type;
  13250. }
  13251. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  13252. PyObject *mro;
  13253. if (a == b) return 1;
  13254. mro = a->tp_mro;
  13255. if (likely(mro)) {
  13256. Py_ssize_t i, n;
  13257. n = PyTuple_GET_SIZE(mro);
  13258. for (i = 0; i < n; i++) {
  13259. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  13260. return 1;
  13261. }
  13262. return 0;
  13263. }
  13264. return __Pyx_InBases(a, b);
  13265. }
  13266. static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) {
  13267. PyObject *mro;
  13268. if (cls == a || cls == b) return 1;
  13269. mro = cls->tp_mro;
  13270. if (likely(mro)) {
  13271. Py_ssize_t i, n;
  13272. n = PyTuple_GET_SIZE(mro);
  13273. for (i = 0; i < n; i++) {
  13274. PyObject *base = PyTuple_GET_ITEM(mro, i);
  13275. if (base == (PyObject *)a || base == (PyObject *)b)
  13276. return 1;
  13277. }
  13278. return 0;
  13279. }
  13280. return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b);
  13281. }
  13282. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  13283. if (exc_type1) {
  13284. return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2);
  13285. } else {
  13286. return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  13287. }
  13288. }
  13289. static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  13290. Py_ssize_t i, n;
  13291. assert(PyExceptionClass_Check(exc_type));
  13292. n = PyTuple_GET_SIZE(tuple);
  13293. for (i=0; i<n; i++) {
  13294. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  13295. }
  13296. for (i=0; i<n; i++) {
  13297. PyObject *t = PyTuple_GET_ITEM(tuple, i);
  13298. if (likely(PyExceptionClass_Check(t))) {
  13299. if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
  13300. } else {
  13301. }
  13302. }
  13303. return 0;
  13304. }
  13305. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  13306. if (likely(err == exc_type)) return 1;
  13307. if (likely(PyExceptionClass_Check(err))) {
  13308. if (likely(PyExceptionClass_Check(exc_type))) {
  13309. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  13310. } else if (likely(PyTuple_Check(exc_type))) {
  13311. return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
  13312. } else {
  13313. }
  13314. }
  13315. return PyErr_GivenExceptionMatches(err, exc_type);
  13316. }
  13317. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  13318. assert(PyExceptionClass_Check(exc_type1));
  13319. assert(PyExceptionClass_Check(exc_type2));
  13320. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  13321. if (likely(PyExceptionClass_Check(err))) {
  13322. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  13323. }
  13324. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  13325. }
  13326. #endif
  13327. /* GetRuntimeVersion */
  13328. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  13329. void __Pyx_init_runtime_version(void) {
  13330. if (__Pyx_cached_runtime_version == 0) {
  13331. const char* rt_version = Py_GetVersion();
  13332. unsigned long version = 0;
  13333. unsigned long factor = 0x01000000UL;
  13334. unsigned int digit = 0;
  13335. int i = 0;
  13336. while (factor) {
  13337. while ('0' <= rt_version[i] && rt_version[i] <= '9') {
  13338. digit = digit * 10 + (unsigned int) (rt_version[i] - '0');
  13339. ++i;
  13340. }
  13341. version += factor * digit;
  13342. if (rt_version[i] != '.')
  13343. break;
  13344. digit = 0;
  13345. factor >>= 8;
  13346. ++i;
  13347. }
  13348. __Pyx_cached_runtime_version = version;
  13349. }
  13350. }
  13351. #endif
  13352. static unsigned long __Pyx_get_runtime_version(void) {
  13353. #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
  13354. return Py_Version & ~0xFFUL;
  13355. #else
  13356. return __Pyx_cached_runtime_version;
  13357. #endif
  13358. }
  13359. /* SwapException (used by CoroutineBase) */
  13360. #if CYTHON_FAST_THREAD_STATE
  13361. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  13362. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13363. #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
  13364. _PyErr_StackItem *exc_info = tstate->exc_info;
  13365. tmp_value = exc_info->exc_value;
  13366. exc_info->exc_value = *value;
  13367. if (tmp_value == NULL || tmp_value == Py_None) {
  13368. Py_XDECREF(tmp_value);
  13369. tmp_value = NULL;
  13370. tmp_type = NULL;
  13371. tmp_tb = NULL;
  13372. } else {
  13373. tmp_type = (PyObject*) Py_TYPE(tmp_value);
  13374. Py_INCREF(tmp_type);
  13375. #if CYTHON_COMPILING_IN_CPYTHON
  13376. tmp_tb = ((PyBaseExceptionObject*) tmp_value)->traceback;
  13377. Py_XINCREF(tmp_tb);
  13378. #else
  13379. tmp_tb = PyException_GetTraceback(tmp_value);
  13380. #endif
  13381. }
  13382. #elif CYTHON_USE_EXC_INFO_STACK
  13383. _PyErr_StackItem *exc_info = tstate->exc_info;
  13384. tmp_type = exc_info->exc_type;
  13385. tmp_value = exc_info->exc_value;
  13386. tmp_tb = exc_info->exc_traceback;
  13387. exc_info->exc_type = *type;
  13388. exc_info->exc_value = *value;
  13389. exc_info->exc_traceback = *tb;
  13390. #else
  13391. tmp_type = tstate->exc_type;
  13392. tmp_value = tstate->exc_value;
  13393. tmp_tb = tstate->exc_traceback;
  13394. tstate->exc_type = *type;
  13395. tstate->exc_value = *value;
  13396. tstate->exc_traceback = *tb;
  13397. #endif
  13398. *type = tmp_type;
  13399. *value = tmp_value;
  13400. *tb = tmp_tb;
  13401. }
  13402. #else
  13403. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
  13404. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13405. PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
  13406. PyErr_SetExcInfo(*type, *value, *tb);
  13407. *type = tmp_type;
  13408. *value = tmp_value;
  13409. *tb = tmp_tb;
  13410. }
  13411. #endif
  13412. /* PyObjectCall2Args (used by PyObjectCallMethod1) */
  13413. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
  13414. PyObject *args[3] = {NULL, arg1, arg2};
  13415. return __Pyx_PyObject_FastCall(function, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  13416. }
  13417. /* PyObjectCallMethod1 (used by CoroutineBase) */
  13418. #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
  13419. static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
  13420. PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
  13421. Py_DECREF(method);
  13422. return result;
  13423. }
  13424. #endif
  13425. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
  13426. #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))
  13427. PyObject *args[2] = {obj, arg};
  13428. (void) __Pyx_PyObject_CallOneArg;
  13429. (void) __Pyx_PyObject_Call2Args;
  13430. return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  13431. #else
  13432. PyObject *method = NULL, *result;
  13433. int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
  13434. if (likely(is_method)) {
  13435. result = __Pyx_PyObject_Call2Args(method, obj, arg);
  13436. Py_DECREF(method);
  13437. return result;
  13438. }
  13439. if (unlikely(!method)) return NULL;
  13440. return __Pyx__PyObject_CallMethod1(method, arg);
  13441. #endif
  13442. }
  13443. /* ReturnWithStopIteration (used by CoroutineBase) */
  13444. static void __Pyx__ReturnWithStopIteration(PyObject* value, int async);
  13445. static CYTHON_INLINE void __Pyx_ReturnWithStopIteration(PyObject* value, int async, int iternext) {
  13446. if (value == Py_None) {
  13447. if (async || !iternext)
  13448. PyErr_SetNone(async ? PyExc_StopAsyncIteration : PyExc_StopIteration);
  13449. return;
  13450. }
  13451. __Pyx__ReturnWithStopIteration(value, async);
  13452. }
  13453. static void __Pyx__ReturnWithStopIteration(PyObject* value, int async) {
  13454. #if CYTHON_COMPILING_IN_CPYTHON
  13455. __Pyx_PyThreadState_declare
  13456. #endif
  13457. PyObject *exc;
  13458. PyObject *exc_type = async ? PyExc_StopAsyncIteration : PyExc_StopIteration;
  13459. #if CYTHON_COMPILING_IN_CPYTHON
  13460. if ((PY_VERSION_HEX >= (0x030C00A6)) || unlikely(PyTuple_Check(value) || PyExceptionInstance_Check(value))) {
  13461. if (PY_VERSION_HEX >= (0x030e00A1)) {
  13462. exc = __Pyx_PyObject_CallOneArg(exc_type, value);
  13463. } else {
  13464. PyObject *args_tuple = PyTuple_New(1);
  13465. if (unlikely(!args_tuple)) return;
  13466. Py_INCREF(value);
  13467. PyTuple_SET_ITEM(args_tuple, 0, value);
  13468. exc = PyObject_Call(exc_type, args_tuple, NULL);
  13469. Py_DECREF(args_tuple);
  13470. }
  13471. if (unlikely(!exc)) return;
  13472. } else {
  13473. Py_INCREF(value);
  13474. exc = value;
  13475. }
  13476. #if CYTHON_FAST_THREAD_STATE
  13477. __Pyx_PyThreadState_assign
  13478. #if CYTHON_USE_EXC_INFO_STACK
  13479. if (!__pyx_tstate->exc_info->exc_value)
  13480. #else
  13481. if (!__pyx_tstate->exc_type)
  13482. #endif
  13483. {
  13484. Py_INCREF(exc_type);
  13485. __Pyx_ErrRestore(exc_type, exc, NULL);
  13486. return;
  13487. }
  13488. #endif
  13489. #else
  13490. exc = __Pyx_PyObject_CallOneArg(exc_type, value);
  13491. if (unlikely(!exc)) return;
  13492. #endif
  13493. PyErr_SetObject(exc_type, exc);
  13494. Py_DECREF(exc);
  13495. }
  13496. /* CoroutineBase (used by Generator) */
  13497. #if !CYTHON_COMPILING_IN_LIMITED_API
  13498. #include <frameobject.h>
  13499. #if PY_VERSION_HEX >= 0x030b00a6 && !defined(PYPY_VERSION)
  13500. #ifndef Py_BUILD_CORE
  13501. #define Py_BUILD_CORE 1
  13502. #endif
  13503. #include "internal/pycore_frame.h"
  13504. #endif
  13505. #endif // CYTHON_COMPILING_IN_LIMITED_API
  13506. static CYTHON_INLINE void
  13507. __Pyx_Coroutine_Undelegate(__pyx_CoroutineObject *gen) {
  13508. #if CYTHON_USE_AM_SEND
  13509. gen->yieldfrom_am_send = NULL;
  13510. #endif
  13511. Py_CLEAR(gen->yieldfrom);
  13512. }
  13513. static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *__pyx_tstate, PyObject **pvalue) {
  13514. PyObject *et, *ev, *tb;
  13515. PyObject *value = NULL;
  13516. CYTHON_UNUSED_VAR(__pyx_tstate);
  13517. __Pyx_ErrFetch(&et, &ev, &tb);
  13518. if (!et) {
  13519. Py_XDECREF(tb);
  13520. Py_XDECREF(ev);
  13521. Py_INCREF(Py_None);
  13522. *pvalue = Py_None;
  13523. return 0;
  13524. }
  13525. if (likely(et == PyExc_StopIteration)) {
  13526. if (!ev) {
  13527. Py_INCREF(Py_None);
  13528. value = Py_None;
  13529. }
  13530. else if (likely(__Pyx_IS_TYPE(ev, (PyTypeObject*)PyExc_StopIteration))) {
  13531. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
  13532. value = PyObject_GetAttr(ev, __pyx_mstate_global->__pyx_n_u_value);
  13533. if (unlikely(!value)) goto limited_api_failure;
  13534. #else
  13535. value = ((PyStopIterationObject *)ev)->value;
  13536. Py_INCREF(value);
  13537. #endif
  13538. Py_DECREF(ev);
  13539. }
  13540. else if (unlikely(PyTuple_Check(ev))) {
  13541. Py_ssize_t tuple_size = __Pyx_PyTuple_GET_SIZE(ev);
  13542. #if !CYTHON_ASSUME_SAFE_SIZE
  13543. if (unlikely(tuple_size < 0)) {
  13544. Py_XDECREF(tb);
  13545. Py_DECREF(ev);
  13546. Py_DECREF(et);
  13547. return -1;
  13548. }
  13549. #endif
  13550. if (tuple_size >= 1) {
  13551. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  13552. value = PyTuple_GET_ITEM(ev, 0);
  13553. Py_INCREF(value);
  13554. #elif CYTHON_ASSUME_SAFE_MACROS
  13555. value = PySequence_ITEM(ev, 0);
  13556. #else
  13557. value = PySequence_GetItem(ev, 0);
  13558. if (!value) goto limited_api_failure;
  13559. #endif
  13560. } else {
  13561. Py_INCREF(Py_None);
  13562. value = Py_None;
  13563. }
  13564. Py_DECREF(ev);
  13565. }
  13566. else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
  13567. value = ev;
  13568. }
  13569. if (likely(value)) {
  13570. Py_XDECREF(tb);
  13571. Py_DECREF(et);
  13572. *pvalue = value;
  13573. return 0;
  13574. }
  13575. } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
  13576. __Pyx_ErrRestore(et, ev, tb);
  13577. return -1;
  13578. }
  13579. PyErr_NormalizeException(&et, &ev, &tb);
  13580. if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
  13581. __Pyx_ErrRestore(et, ev, tb);
  13582. return -1;
  13583. }
  13584. Py_XDECREF(tb);
  13585. Py_DECREF(et);
  13586. #if CYTHON_COMPILING_IN_LIMITED_API
  13587. value = PyObject_GetAttr(ev, __pyx_mstate_global->__pyx_n_u_value);
  13588. #else
  13589. value = ((PyStopIterationObject *)ev)->value;
  13590. Py_INCREF(value);
  13591. #endif
  13592. Py_DECREF(ev);
  13593. #if CYTHON_COMPILING_IN_LIMITED_API
  13594. if (unlikely(!value)) return -1;
  13595. #endif
  13596. *pvalue = value;
  13597. return 0;
  13598. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL || !CYTHON_ASSUME_SAFE_MACROS
  13599. limited_api_failure:
  13600. Py_XDECREF(et);
  13601. Py_XDECREF(tb);
  13602. Py_XDECREF(ev);
  13603. return -1;
  13604. #endif
  13605. }
  13606. static CYTHON_INLINE
  13607. __Pyx_PySendResult __Pyx_Coroutine_status_from_result(PyObject **retval) {
  13608. if (*retval) {
  13609. return PYGEN_NEXT;
  13610. } else if (likely(__Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, retval) == 0)) {
  13611. return PYGEN_RETURN;
  13612. } else {
  13613. return PYGEN_ERROR;
  13614. }
  13615. }
  13616. static CYTHON_INLINE
  13617. void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
  13618. #if PY_VERSION_HEX >= 0x030B00a4
  13619. Py_CLEAR(exc_state->exc_value);
  13620. #else
  13621. PyObject *t, *v, *tb;
  13622. t = exc_state->exc_type;
  13623. v = exc_state->exc_value;
  13624. tb = exc_state->exc_traceback;
  13625. exc_state->exc_type = NULL;
  13626. exc_state->exc_value = NULL;
  13627. exc_state->exc_traceback = NULL;
  13628. Py_XDECREF(t);
  13629. Py_XDECREF(v);
  13630. Py_XDECREF(tb);
  13631. #endif
  13632. }
  13633. #define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
  13634. static void __Pyx__Coroutine_AlreadyRunningError(__pyx_CoroutineObject *gen) {
  13635. const char *msg;
  13636. CYTHON_MAYBE_UNUSED_VAR(gen);
  13637. if ((0)) {
  13638. #ifdef __Pyx_Coroutine_USED
  13639. } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
  13640. msg = "coroutine already executing";
  13641. #endif
  13642. #ifdef __Pyx_AsyncGen_USED
  13643. } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
  13644. msg = "async generator already executing";
  13645. #endif
  13646. } else {
  13647. msg = "generator already executing";
  13648. }
  13649. PyErr_SetString(PyExc_ValueError, msg);
  13650. }
  13651. static void __Pyx_Coroutine_AlreadyTerminatedError(PyObject *gen, PyObject *value, int closing) {
  13652. CYTHON_MAYBE_UNUSED_VAR(gen);
  13653. CYTHON_MAYBE_UNUSED_VAR(closing);
  13654. #ifdef __Pyx_Coroutine_USED
  13655. if (!closing && __Pyx_Coroutine_Check(gen)) {
  13656. PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
  13657. } else
  13658. #endif
  13659. if (value) {
  13660. #ifdef __Pyx_AsyncGen_USED
  13661. if (__Pyx_AsyncGen_CheckExact(gen))
  13662. PyErr_SetNone(PyExc_StopAsyncIteration);
  13663. else
  13664. #endif
  13665. PyErr_SetNone(PyExc_StopIteration);
  13666. }
  13667. }
  13668. static
  13669. __Pyx_PySendResult __Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, PyObject **result, int closing) {
  13670. __Pyx_PyThreadState_declare
  13671. PyThreadState *tstate;
  13672. __Pyx_ExcInfoStruct *exc_state;
  13673. PyObject *retval;
  13674. assert(__Pyx_Coroutine_get_is_running(self)); // Callers should ensure is_running
  13675. if (unlikely(self->resume_label == -1)) {
  13676. __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
  13677. return PYGEN_ERROR;
  13678. }
  13679. #if CYTHON_FAST_THREAD_STATE
  13680. __Pyx_PyThreadState_assign
  13681. tstate = __pyx_tstate;
  13682. #else
  13683. tstate = __Pyx_PyThreadState_Current;
  13684. #endif
  13685. exc_state = &self->gi_exc_state;
  13686. if (exc_state->exc_value) {
  13687. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
  13688. #else
  13689. PyObject *exc_tb;
  13690. #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON
  13691. exc_tb = PyException_GetTraceback(exc_state->exc_value);
  13692. #elif PY_VERSION_HEX >= 0x030B00a4
  13693. exc_tb = ((PyBaseExceptionObject*) exc_state->exc_value)->traceback;
  13694. #else
  13695. exc_tb = exc_state->exc_traceback;
  13696. #endif
  13697. if (exc_tb) {
  13698. PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
  13699. PyFrameObject *f = tb->tb_frame;
  13700. assert(f->f_back == NULL);
  13701. #if PY_VERSION_HEX >= 0x030B00A1
  13702. f->f_back = PyThreadState_GetFrame(tstate);
  13703. #else
  13704. Py_XINCREF(tstate->frame);
  13705. f->f_back = tstate->frame;
  13706. #endif
  13707. #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON
  13708. Py_DECREF(exc_tb);
  13709. #endif
  13710. }
  13711. #endif
  13712. }
  13713. #if CYTHON_USE_EXC_INFO_STACK
  13714. exc_state->previous_item = tstate->exc_info;
  13715. tstate->exc_info = exc_state;
  13716. #else
  13717. if (exc_state->exc_type) {
  13718. __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
  13719. } else {
  13720. __Pyx_Coroutine_ExceptionClear(exc_state);
  13721. __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
  13722. }
  13723. #endif
  13724. retval = self->body(self, tstate, value);
  13725. #if CYTHON_USE_EXC_INFO_STACK
  13726. exc_state = &self->gi_exc_state;
  13727. tstate->exc_info = exc_state->previous_item;
  13728. exc_state->previous_item = NULL;
  13729. __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
  13730. #endif
  13731. *result = retval;
  13732. if (self->resume_label == -1) {
  13733. return likely(retval) ? PYGEN_RETURN : PYGEN_ERROR;
  13734. }
  13735. return PYGEN_NEXT;
  13736. }
  13737. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
  13738. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API
  13739. CYTHON_UNUSED_VAR(exc_state);
  13740. #else
  13741. PyObject *exc_tb;
  13742. #if PY_VERSION_HEX >= 0x030B00a4
  13743. if (!exc_state->exc_value) return;
  13744. exc_tb = PyException_GetTraceback(exc_state->exc_value);
  13745. #else
  13746. exc_tb = exc_state->exc_traceback;
  13747. #endif
  13748. if (likely(exc_tb)) {
  13749. PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
  13750. PyFrameObject *f = tb->tb_frame;
  13751. Py_CLEAR(f->f_back);
  13752. #if PY_VERSION_HEX >= 0x030B00a4
  13753. Py_DECREF(exc_tb);
  13754. #endif
  13755. }
  13756. #endif
  13757. }
  13758. #define __Pyx_Coroutine_MethodReturnFromResult(gen, result, retval, iternext)\
  13759. ((result) == PYGEN_NEXT ? (retval) : __Pyx__Coroutine_MethodReturnFromResult(gen, result, retval, iternext))
  13760. static PyObject *
  13761. __Pyx__Coroutine_MethodReturnFromResult(PyObject* gen, __Pyx_PySendResult result, PyObject *retval, int iternext) {
  13762. CYTHON_MAYBE_UNUSED_VAR(gen);
  13763. if (likely(result == PYGEN_RETURN)) {
  13764. int is_async = 0;
  13765. #ifdef __Pyx_AsyncGen_USED
  13766. is_async = __Pyx_AsyncGen_CheckExact(gen);
  13767. #endif
  13768. __Pyx_ReturnWithStopIteration(retval, is_async, iternext);
  13769. Py_XDECREF(retval);
  13770. }
  13771. return NULL;
  13772. }
  13773. #if CYTHON_COMPILING_IN_CPYTHON
  13774. static CYTHON_INLINE
  13775. PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) {
  13776. #if PY_VERSION_HEX <= 0x030A00A1
  13777. return _PyGen_Send(gen, arg);
  13778. #else
  13779. PyObject *result;
  13780. if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) {
  13781. if (PyAsyncGen_CheckExact(gen)) {
  13782. assert(result == Py_None);
  13783. PyErr_SetNone(PyExc_StopAsyncIteration);
  13784. }
  13785. else if (result == Py_None) {
  13786. PyErr_SetNone(PyExc_StopIteration);
  13787. }
  13788. else {
  13789. #if PY_VERSION_HEX < 0x030d00A1
  13790. _PyGen_SetStopIterationValue(result);
  13791. #else
  13792. if (!PyTuple_Check(result) && !PyExceptionInstance_Check(result)) {
  13793. PyErr_SetObject(PyExc_StopIteration, result);
  13794. } else {
  13795. PyObject *exc = __Pyx_PyObject_CallOneArg(PyExc_StopIteration, result);
  13796. if (likely(exc != NULL)) {
  13797. PyErr_SetObject(PyExc_StopIteration, exc);
  13798. Py_DECREF(exc);
  13799. }
  13800. }
  13801. #endif
  13802. }
  13803. Py_DECREF(result);
  13804. result = NULL;
  13805. }
  13806. return result;
  13807. #endif
  13808. }
  13809. #endif
  13810. static CYTHON_INLINE __Pyx_PySendResult
  13811. __Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen, PyObject** retval) {
  13812. __Pyx_PySendResult result;
  13813. PyObject *val = NULL;
  13814. assert(__Pyx_Coroutine_get_is_running(gen));
  13815. __Pyx_Coroutine_Undelegate(gen);
  13816. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
  13817. result = __Pyx_Coroutine_SendEx(gen, val, retval, 0);
  13818. Py_XDECREF(val);
  13819. return result;
  13820. }
  13821. #if CYTHON_USE_AM_SEND
  13822. static __Pyx_PySendResult
  13823. __Pyx_Coroutine_SendToDelegate(__pyx_CoroutineObject *gen, __Pyx_pyiter_sendfunc gen_am_send, PyObject *value, PyObject **retval) {
  13824. PyObject *ret = NULL;
  13825. __Pyx_PySendResult delegate_result, result;
  13826. assert(__Pyx_Coroutine_get_is_running(gen));
  13827. delegate_result = gen_am_send(gen->yieldfrom, value, &ret);
  13828. if (delegate_result == PYGEN_NEXT) {
  13829. assert (ret != NULL);
  13830. *retval = ret;
  13831. return PYGEN_NEXT;
  13832. }
  13833. assert (delegate_result != PYGEN_ERROR || ret == NULL);
  13834. __Pyx_Coroutine_Undelegate(gen);
  13835. result = __Pyx_Coroutine_SendEx(gen, ret, retval, 0);
  13836. Py_XDECREF(ret);
  13837. return result;
  13838. }
  13839. #endif
  13840. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
  13841. PyObject *retval = NULL;
  13842. __Pyx_PySendResult result = __Pyx_Coroutine_AmSend(self, value, &retval);
  13843. return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 0);
  13844. }
  13845. static __Pyx_PySendResult
  13846. __Pyx_Coroutine_AmSend(PyObject *self, PyObject *value, PyObject **retval) {
  13847. __Pyx_PySendResult result;
  13848. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  13849. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  13850. *retval = __Pyx_Coroutine_AlreadyRunningError(gen);
  13851. return PYGEN_ERROR;
  13852. }
  13853. #if CYTHON_USE_AM_SEND
  13854. if (gen->yieldfrom_am_send) {
  13855. result = __Pyx_Coroutine_SendToDelegate(gen, gen->yieldfrom_am_send, value, retval);
  13856. } else
  13857. #endif
  13858. if (gen->yieldfrom) {
  13859. PyObject *yf = gen->yieldfrom;
  13860. PyObject *ret;
  13861. #if !CYTHON_USE_AM_SEND
  13862. #ifdef __Pyx_Generator_USED
  13863. if (__Pyx_Generator_CheckExact(yf)) {
  13864. ret = __Pyx_Coroutine_Send(yf, value);
  13865. } else
  13866. #endif
  13867. #ifdef __Pyx_Coroutine_USED
  13868. if (__Pyx_Coroutine_Check(yf)) {
  13869. ret = __Pyx_Coroutine_Send(yf, value);
  13870. } else
  13871. #endif
  13872. #ifdef __Pyx_AsyncGen_USED
  13873. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  13874. ret = __Pyx_async_gen_asend_send(yf, value);
  13875. } else
  13876. #endif
  13877. #if CYTHON_COMPILING_IN_CPYTHON
  13878. if (PyGen_CheckExact(yf)) {
  13879. ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  13880. } else
  13881. if (PyCoro_CheckExact(yf)) {
  13882. ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  13883. } else
  13884. #endif
  13885. #endif
  13886. {
  13887. #if !CYTHON_COMPILING_IN_LIMITED_API || __PYX_LIMITED_VERSION_HEX >= 0x03080000
  13888. if (value == Py_None && PyIter_Check(yf))
  13889. ret = __Pyx_PyIter_Next_Plain(yf);
  13890. else
  13891. #endif
  13892. ret = __Pyx_PyObject_CallMethod1(yf, __pyx_mstate_global->__pyx_n_u_send, value);
  13893. }
  13894. if (likely(ret)) {
  13895. __Pyx_Coroutine_unset_is_running(gen);
  13896. *retval = ret;
  13897. return PYGEN_NEXT;
  13898. }
  13899. result = __Pyx_Coroutine_FinishDelegation(gen, retval);
  13900. } else {
  13901. result = __Pyx_Coroutine_SendEx(gen, value, retval, 0);
  13902. }
  13903. __Pyx_Coroutine_unset_is_running(gen);
  13904. return result;
  13905. }
  13906. static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
  13907. __Pyx_PySendResult result;
  13908. PyObject *retval = NULL;
  13909. CYTHON_UNUSED_VAR(gen);
  13910. assert(__Pyx_Coroutine_get_is_running(gen));
  13911. #ifdef __Pyx_Generator_USED
  13912. if (__Pyx_Generator_CheckExact(yf)) {
  13913. result = __Pyx_Coroutine_Close(yf, &retval);
  13914. } else
  13915. #endif
  13916. #ifdef __Pyx_Coroutine_USED
  13917. if (__Pyx_Coroutine_Check(yf)) {
  13918. result = __Pyx_Coroutine_Close(yf, &retval);
  13919. } else
  13920. if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  13921. result = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf);
  13922. } else
  13923. #endif
  13924. #ifdef __Pyx_AsyncGen_USED
  13925. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  13926. retval = __Pyx_async_gen_asend_close(yf, NULL);
  13927. result = PYGEN_RETURN;
  13928. } else
  13929. if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
  13930. retval = __Pyx_async_gen_athrow_close(yf, NULL);
  13931. result = PYGEN_RETURN;
  13932. } else
  13933. #endif
  13934. {
  13935. PyObject *meth;
  13936. result = PYGEN_RETURN;
  13937. meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_mstate_global->__pyx_n_u_close);
  13938. if (unlikely(!meth)) {
  13939. if (unlikely(PyErr_Occurred())) {
  13940. PyErr_WriteUnraisable(yf);
  13941. }
  13942. } else {
  13943. retval = __Pyx_PyObject_CallNoArg(meth);
  13944. Py_DECREF(meth);
  13945. if (unlikely(!retval)) {
  13946. result = PYGEN_ERROR;
  13947. }
  13948. }
  13949. }
  13950. Py_XDECREF(retval);
  13951. return result == PYGEN_ERROR ? -1 : 0;
  13952. }
  13953. static PyObject *__Pyx_Generator_Next(PyObject *self) {
  13954. __Pyx_PySendResult result;
  13955. PyObject *retval = NULL;
  13956. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  13957. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  13958. return __Pyx_Coroutine_AlreadyRunningError(gen);
  13959. }
  13960. #if CYTHON_USE_AM_SEND
  13961. if (gen->yieldfrom_am_send) {
  13962. result = __Pyx_Coroutine_SendToDelegate(gen, gen->yieldfrom_am_send, Py_None, &retval);
  13963. } else
  13964. #endif
  13965. if (gen->yieldfrom) {
  13966. PyObject *yf = gen->yieldfrom;
  13967. PyObject *ret;
  13968. #ifdef __Pyx_Generator_USED
  13969. if (__Pyx_Generator_CheckExact(yf)) {
  13970. ret = __Pyx_Generator_Next(yf);
  13971. } else
  13972. #endif
  13973. #ifdef __Pyx_Coroutine_USED
  13974. if (__Pyx_Coroutine_CheckExact(yf)) {
  13975. ret = __Pyx_Coroutine_Send(yf, Py_None);
  13976. } else
  13977. #endif
  13978. #if CYTHON_COMPILING_IN_CPYTHON && (PY_VERSION_HEX < 0x030A00A3 || !CYTHON_USE_AM_SEND)
  13979. if (PyGen_CheckExact(yf)) {
  13980. ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL);
  13981. } else
  13982. #endif
  13983. ret = __Pyx_PyIter_Next_Plain(yf);
  13984. if (likely(ret)) {
  13985. __Pyx_Coroutine_unset_is_running(gen);
  13986. return ret;
  13987. }
  13988. result = __Pyx_Coroutine_FinishDelegation(gen, &retval);
  13989. } else {
  13990. result = __Pyx_Coroutine_SendEx(gen, Py_None, &retval, 0);
  13991. }
  13992. __Pyx_Coroutine_unset_is_running(gen);
  13993. return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 1);
  13994. }
  13995. static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, PyObject *arg) {
  13996. PyObject *retval = NULL;
  13997. __Pyx_PySendResult result;
  13998. CYTHON_UNUSED_VAR(arg);
  13999. result = __Pyx_Coroutine_Close(self, &retval);
  14000. if (unlikely(result == PYGEN_ERROR))
  14001. return NULL;
  14002. Py_XDECREF(retval);
  14003. Py_RETURN_NONE;
  14004. }
  14005. static __Pyx_PySendResult
  14006. __Pyx_Coroutine_Close(PyObject *self, PyObject **retval) {
  14007. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  14008. __Pyx_PySendResult result;
  14009. PyObject *yf;
  14010. int err = 0;
  14011. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  14012. *retval = __Pyx_Coroutine_AlreadyRunningError(gen);
  14013. return PYGEN_ERROR;
  14014. }
  14015. yf = gen->yieldfrom;
  14016. if (yf) {
  14017. Py_INCREF(yf);
  14018. err = __Pyx_Coroutine_CloseIter(gen, yf);
  14019. __Pyx_Coroutine_Undelegate(gen);
  14020. Py_DECREF(yf);
  14021. }
  14022. if (err == 0)
  14023. PyErr_SetNone(PyExc_GeneratorExit);
  14024. result = __Pyx_Coroutine_SendEx(gen, NULL, retval, 1);
  14025. if (result == PYGEN_ERROR) {
  14026. __Pyx_PyThreadState_declare
  14027. __Pyx_PyThreadState_assign
  14028. __Pyx_Coroutine_unset_is_running(gen);
  14029. if (!__Pyx_PyErr_Occurred()) {
  14030. return PYGEN_RETURN;
  14031. } else if (likely(__Pyx_PyErr_ExceptionMatches2(PyExc_GeneratorExit, PyExc_StopIteration))) {
  14032. __Pyx_PyErr_Clear();
  14033. return PYGEN_RETURN;
  14034. }
  14035. return PYGEN_ERROR;
  14036. } else if (likely(result == PYGEN_RETURN && *retval == Py_None)) {
  14037. __Pyx_Coroutine_unset_is_running(gen);
  14038. return PYGEN_RETURN;
  14039. } else {
  14040. const char *msg;
  14041. Py_DECREF(*retval);
  14042. *retval = NULL;
  14043. if ((0)) {
  14044. #ifdef __Pyx_Coroutine_USED
  14045. } else if (__Pyx_Coroutine_Check(self)) {
  14046. msg = "coroutine ignored GeneratorExit";
  14047. #endif
  14048. #ifdef __Pyx_AsyncGen_USED
  14049. } else if (__Pyx_AsyncGen_CheckExact(self)) {
  14050. msg = "async generator ignored GeneratorExit";
  14051. #endif
  14052. } else {
  14053. msg = "generator ignored GeneratorExit";
  14054. }
  14055. PyErr_SetString(PyExc_RuntimeError, msg);
  14056. __Pyx_Coroutine_unset_is_running(gen);
  14057. return PYGEN_ERROR;
  14058. }
  14059. }
  14060. static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
  14061. PyObject *args, int close_on_genexit) {
  14062. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  14063. PyObject *yf;
  14064. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen)))
  14065. return __Pyx_Coroutine_AlreadyRunningError(gen);
  14066. yf = gen->yieldfrom;
  14067. if (yf) {
  14068. __Pyx_PySendResult result;
  14069. PyObject *ret;
  14070. Py_INCREF(yf);
  14071. if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
  14072. int err = __Pyx_Coroutine_CloseIter(gen, yf);
  14073. Py_DECREF(yf);
  14074. __Pyx_Coroutine_Undelegate(gen);
  14075. if (err < 0)
  14076. goto propagate_exception;
  14077. goto throw_here;
  14078. }
  14079. if (0
  14080. #ifdef __Pyx_Generator_USED
  14081. || __Pyx_Generator_CheckExact(yf)
  14082. #endif
  14083. #ifdef __Pyx_Coroutine_USED
  14084. || __Pyx_Coroutine_Check(yf)
  14085. #endif
  14086. ) {
  14087. ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
  14088. #ifdef __Pyx_Coroutine_USED
  14089. } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  14090. ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
  14091. #endif
  14092. } else {
  14093. PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_mstate_global->__pyx_n_u_throw);
  14094. if (unlikely(!meth)) {
  14095. Py_DECREF(yf);
  14096. if (unlikely(PyErr_Occurred())) {
  14097. __Pyx_Coroutine_unset_is_running(gen);
  14098. return NULL;
  14099. }
  14100. __Pyx_Coroutine_Undelegate(gen);
  14101. goto throw_here;
  14102. }
  14103. if (likely(args)) {
  14104. ret = __Pyx_PyObject_Call(meth, args, NULL);
  14105. } else {
  14106. PyObject *cargs[4] = {NULL, typ, val, tb};
  14107. ret = __Pyx_PyObject_FastCall(meth, cargs+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  14108. }
  14109. Py_DECREF(meth);
  14110. }
  14111. Py_DECREF(yf);
  14112. if (ret) {
  14113. __Pyx_Coroutine_unset_is_running(gen);
  14114. return ret;
  14115. }
  14116. result = __Pyx_Coroutine_FinishDelegation(gen, &ret);
  14117. __Pyx_Coroutine_unset_is_running(gen);
  14118. return __Pyx_Coroutine_MethodReturnFromResult(self, result, ret, 0);
  14119. }
  14120. throw_here:
  14121. __Pyx_Raise(typ, val, tb, NULL);
  14122. propagate_exception:
  14123. {
  14124. PyObject *retval = NULL;
  14125. __Pyx_PySendResult result = __Pyx_Coroutine_SendEx(gen, NULL, &retval, 0);
  14126. __Pyx_Coroutine_unset_is_running(gen);
  14127. return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 0);
  14128. }
  14129. }
  14130. static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
  14131. PyObject *typ;
  14132. PyObject *val = NULL;
  14133. PyObject *tb = NULL;
  14134. if (unlikely(!PyArg_UnpackTuple(args, "throw", 1, 3, &typ, &val, &tb)))
  14135. return NULL;
  14136. return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
  14137. }
  14138. static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
  14139. #if PY_VERSION_HEX >= 0x030B00a4
  14140. Py_VISIT(exc_state->exc_value);
  14141. #else
  14142. Py_VISIT(exc_state->exc_type);
  14143. Py_VISIT(exc_state->exc_value);
  14144. Py_VISIT(exc_state->exc_traceback);
  14145. #endif
  14146. return 0;
  14147. }
  14148. static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
  14149. {
  14150. int e = __Pyx_call_type_traverse((PyObject*)gen, 1, visit, arg);
  14151. if (e) return e;
  14152. }
  14153. Py_VISIT(gen->closure);
  14154. Py_VISIT(gen->classobj);
  14155. Py_VISIT(gen->yieldfrom);
  14156. return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
  14157. }
  14158. static int __Pyx_Coroutine_clear(PyObject *self) {
  14159. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  14160. Py_CLEAR(gen->closure);
  14161. Py_CLEAR(gen->classobj);
  14162. __Pyx_Coroutine_Undelegate(gen);
  14163. __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
  14164. #ifdef __Pyx_AsyncGen_USED
  14165. if (__Pyx_AsyncGen_CheckExact(self)) {
  14166. Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
  14167. }
  14168. #endif
  14169. Py_CLEAR(gen->gi_code);
  14170. Py_CLEAR(gen->gi_frame);
  14171. Py_CLEAR(gen->gi_name);
  14172. Py_CLEAR(gen->gi_qualname);
  14173. Py_CLEAR(gen->gi_modulename);
  14174. return 0;
  14175. }
  14176. static void __Pyx_Coroutine_dealloc(PyObject *self) {
  14177. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  14178. PyObject_GC_UnTrack(gen);
  14179. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  14180. if (gen->gi_weakreflist != NULL)
  14181. #endif
  14182. PyObject_ClearWeakRefs(self);
  14183. if (gen->resume_label >= 0) {
  14184. PyObject_GC_Track(self);
  14185. #if CYTHON_USE_TP_FINALIZE
  14186. if (unlikely(PyObject_CallFinalizerFromDealloc(self)))
  14187. #else
  14188. {
  14189. destructor del = __Pyx_PyObject_GetSlot(gen, tp_del, destructor);
  14190. if (del) del(self);
  14191. }
  14192. if (unlikely(Py_REFCNT(self) > 0))
  14193. #endif
  14194. {
  14195. return;
  14196. }
  14197. PyObject_GC_UnTrack(self);
  14198. }
  14199. #ifdef __Pyx_AsyncGen_USED
  14200. if (__Pyx_AsyncGen_CheckExact(self)) {
  14201. /* We have to handle this case for asynchronous generators
  14202. right here, because this code has to be between UNTRACK
  14203. and GC_Del. */
  14204. Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
  14205. }
  14206. #endif
  14207. __Pyx_Coroutine_clear(self);
  14208. __Pyx_PyHeapTypeObject_GC_Del(gen);
  14209. }
  14210. #if CYTHON_USE_TP_FINALIZE
  14211. static void __Pyx_Coroutine_del(PyObject *self) {
  14212. PyObject *error_type, *error_value, *error_traceback;
  14213. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  14214. __Pyx_PyThreadState_declare
  14215. if (gen->resume_label < 0) {
  14216. return;
  14217. }
  14218. __Pyx_PyThreadState_assign
  14219. __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
  14220. #ifdef __Pyx_AsyncGen_USED
  14221. if (__Pyx_AsyncGen_CheckExact(self)) {
  14222. __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
  14223. PyObject *finalizer = agen->ag_finalizer;
  14224. if (finalizer && !agen->ag_closed) {
  14225. PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
  14226. if (unlikely(!res)) {
  14227. PyErr_WriteUnraisable(self);
  14228. } else {
  14229. Py_DECREF(res);
  14230. }
  14231. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  14232. return;
  14233. }
  14234. }
  14235. #endif
  14236. if (unlikely(gen->resume_label == 0 && !error_value)) {
  14237. #ifdef __Pyx_Coroutine_USED
  14238. #ifdef __Pyx_Generator_USED
  14239. if (!__Pyx_Generator_CheckExact(self))
  14240. #endif
  14241. {
  14242. PyObject_GC_UnTrack(self);
  14243. if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
  14244. PyErr_WriteUnraisable(self);
  14245. PyObject_GC_Track(self);
  14246. }
  14247. #endif
  14248. } else {
  14249. PyObject *retval = NULL;
  14250. __Pyx_PySendResult result = __Pyx_Coroutine_Close(self, &retval);
  14251. if (result == PYGEN_ERROR) {
  14252. PyErr_WriteUnraisable(self);
  14253. } else {
  14254. Py_XDECREF(retval);
  14255. }
  14256. }
  14257. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  14258. }
  14259. #endif
  14260. static PyObject *
  14261. __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, void *context)
  14262. {
  14263. PyObject *name = self->gi_name;
  14264. CYTHON_UNUSED_VAR(context);
  14265. if (unlikely(!name)) name = Py_None;
  14266. Py_INCREF(name);
  14267. return name;
  14268. }
  14269. static int
  14270. __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, void *context)
  14271. {
  14272. CYTHON_UNUSED_VAR(context);
  14273. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  14274. PyErr_SetString(PyExc_TypeError,
  14275. "__name__ must be set to a string object");
  14276. return -1;
  14277. }
  14278. Py_INCREF(value);
  14279. __Pyx_Py_XDECREF_SET(self->gi_name, value);
  14280. return 0;
  14281. }
  14282. static PyObject *
  14283. __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, void *context)
  14284. {
  14285. PyObject *name = self->gi_qualname;
  14286. CYTHON_UNUSED_VAR(context);
  14287. if (unlikely(!name)) name = Py_None;
  14288. Py_INCREF(name);
  14289. return name;
  14290. }
  14291. static int
  14292. __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, void *context)
  14293. {
  14294. CYTHON_UNUSED_VAR(context);
  14295. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  14296. PyErr_SetString(PyExc_TypeError,
  14297. "__qualname__ must be set to a string object");
  14298. return -1;
  14299. }
  14300. Py_INCREF(value);
  14301. __Pyx_Py_XDECREF_SET(self->gi_qualname, value);
  14302. return 0;
  14303. }
  14304. static PyObject *
  14305. __Pyx__Coroutine_get_frame(__pyx_CoroutineObject *self)
  14306. {
  14307. #if !CYTHON_COMPILING_IN_LIMITED_API
  14308. PyObject *frame;
  14309. #if PY_VERSION_HEX >= 0x030d0000
  14310. Py_BEGIN_CRITICAL_SECTION(self);
  14311. #endif
  14312. frame = self->gi_frame;
  14313. if (!frame) {
  14314. if (unlikely(!self->gi_code)) {
  14315. Py_RETURN_NONE;
  14316. }
  14317. PyObject *globals = PyDict_New();
  14318. if (unlikely(!globals)) return NULL;
  14319. frame = (PyObject *) PyFrame_New(
  14320. PyThreadState_Get(), /*PyThreadState *tstate,*/
  14321. (PyCodeObject*) self->gi_code, /*PyCodeObject *code,*/
  14322. globals, /*PyObject *globals,*/
  14323. 0 /*PyObject *locals*/
  14324. );
  14325. Py_DECREF(globals);
  14326. if (unlikely(!frame))
  14327. return NULL;
  14328. if (unlikely(self->gi_frame)) {
  14329. Py_DECREF(frame);
  14330. frame = self->gi_frame;
  14331. } else {
  14332. self->gi_frame = frame;
  14333. }
  14334. }
  14335. Py_INCREF(frame);
  14336. #if PY_VERSION_HEX >= 0x030d0000
  14337. Py_END_CRITICAL_SECTION();
  14338. #endif
  14339. return frame;
  14340. #else
  14341. CYTHON_UNUSED_VAR(self);
  14342. Py_RETURN_NONE;
  14343. #endif
  14344. }
  14345. static PyObject *
  14346. __Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, void *context) {
  14347. CYTHON_UNUSED_VAR(context);
  14348. PyObject *frame = self->gi_frame;
  14349. if (frame)
  14350. return __Pyx_NewRef(frame);
  14351. return __Pyx__Coroutine_get_frame(self);
  14352. }
  14353. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  14354. PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  14355. PyObject *name, PyObject *qualname, PyObject *module_name) {
  14356. __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
  14357. if (unlikely(!gen))
  14358. return NULL;
  14359. return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
  14360. }
  14361. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  14362. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  14363. PyObject *name, PyObject *qualname, PyObject *module_name) {
  14364. gen->body = body;
  14365. gen->closure = closure;
  14366. Py_XINCREF(closure);
  14367. gen->is_running = 0;
  14368. gen->resume_label = 0;
  14369. gen->classobj = NULL;
  14370. gen->yieldfrom = NULL;
  14371. gen->yieldfrom_am_send = NULL;
  14372. #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_LIMITED_API
  14373. gen->gi_exc_state.exc_value = NULL;
  14374. #else
  14375. gen->gi_exc_state.exc_type = NULL;
  14376. gen->gi_exc_state.exc_value = NULL;
  14377. gen->gi_exc_state.exc_traceback = NULL;
  14378. #endif
  14379. #if CYTHON_USE_EXC_INFO_STACK
  14380. gen->gi_exc_state.previous_item = NULL;
  14381. #endif
  14382. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  14383. gen->gi_weakreflist = NULL;
  14384. #endif
  14385. Py_XINCREF(qualname);
  14386. gen->gi_qualname = qualname;
  14387. Py_XINCREF(name);
  14388. gen->gi_name = name;
  14389. Py_XINCREF(module_name);
  14390. gen->gi_modulename = module_name;
  14391. Py_XINCREF(code);
  14392. gen->gi_code = code;
  14393. gen->gi_frame = NULL;
  14394. PyObject_GC_Track(gen);
  14395. return gen;
  14396. }
  14397. static char __Pyx_Coroutine_test_and_set_is_running(__pyx_CoroutineObject *gen) {
  14398. char result;
  14399. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14400. Py_BEGIN_CRITICAL_SECTION(gen);
  14401. #endif
  14402. result = gen->is_running;
  14403. gen->is_running = 1;
  14404. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14405. Py_END_CRITICAL_SECTION();
  14406. #endif
  14407. return result;
  14408. }
  14409. static void __Pyx_Coroutine_unset_is_running(__pyx_CoroutineObject *gen) {
  14410. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14411. Py_BEGIN_CRITICAL_SECTION(gen);
  14412. #endif
  14413. assert(gen->is_running);
  14414. gen->is_running = 0;
  14415. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14416. Py_END_CRITICAL_SECTION();
  14417. #endif
  14418. }
  14419. static char __Pyx_Coroutine_get_is_running(__pyx_CoroutineObject *gen) {
  14420. char result;
  14421. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14422. Py_BEGIN_CRITICAL_SECTION(gen);
  14423. #endif
  14424. result = gen->is_running;
  14425. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14426. Py_END_CRITICAL_SECTION();
  14427. #endif
  14428. return result;
  14429. }
  14430. static PyObject *__Pyx_Coroutine_get_is_running_getter(PyObject *gen, void *closure) {
  14431. CYTHON_UNUSED_VAR(closure);
  14432. char result = __Pyx_Coroutine_get_is_running((__pyx_CoroutineObject*)gen);
  14433. if (result) Py_RETURN_TRUE;
  14434. else Py_RETURN_FALSE;
  14435. }
  14436. #if __PYX_HAS_PY_AM_SEND == 2
  14437. static void __Pyx_SetBackportTypeAmSend(PyTypeObject *type, __Pyx_PyAsyncMethodsStruct *static_amsend_methods, __Pyx_pyiter_sendfunc am_send) {
  14438. Py_ssize_t ptr_offset = (char*)(type->tp_as_async) - (char*)type;
  14439. if (ptr_offset < 0 || ptr_offset > type->tp_basicsize) {
  14440. return;
  14441. }
  14442. memcpy((void*)static_amsend_methods, (void*)(type->tp_as_async), sizeof(*type->tp_as_async));
  14443. static_amsend_methods->am_send = am_send;
  14444. type->tp_as_async = __Pyx_SlotTpAsAsync(static_amsend_methods);
  14445. }
  14446. #endif
  14447. static PyObject *__Pyx_Coroutine_fail_reduce_ex(PyObject *self, PyObject *arg) {
  14448. CYTHON_UNUSED_VAR(arg);
  14449. __Pyx_TypeName self_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE((PyObject*)self));
  14450. PyErr_Format(PyExc_TypeError, "cannot pickle '" __Pyx_FMT_TYPENAME "' object",
  14451. self_type_name);
  14452. __Pyx_DECREF_TypeName(self_type_name);
  14453. return NULL;
  14454. }
  14455. /* Generator */
  14456. static PyMethodDef __pyx_Generator_methods[] = {
  14457. {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
  14458. PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
  14459. {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
  14460. PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
  14461. {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
  14462. PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
  14463. {"__reduce_ex__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_O, 0},
  14464. {"__reduce__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_NOARGS, 0},
  14465. {0, 0, 0, 0}
  14466. };
  14467. static PyMemberDef __pyx_Generator_memberlist[] = {
  14468. {"gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
  14469. PyDoc_STR("object being iterated by 'yield from', or None")},
  14470. {"gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
  14471. {"__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), 0, 0},
  14472. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  14473. {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CoroutineObject, gi_weakreflist), READONLY, 0},
  14474. #endif
  14475. {0, 0, 0, 0, 0}
  14476. };
  14477. static PyGetSetDef __pyx_Generator_getsets[] = {
  14478. {"__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
  14479. PyDoc_STR("name of the generator"), 0},
  14480. {"__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
  14481. PyDoc_STR("qualified name of the generator"), 0},
  14482. {"gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL,
  14483. PyDoc_STR("Frame of the generator"), 0},
  14484. {"gi_running", __Pyx_Coroutine_get_is_running_getter, NULL, NULL, NULL},
  14485. {0, 0, 0, 0, 0}
  14486. };
  14487. static PyType_Slot __pyx_GeneratorType_slots[] = {
  14488. {Py_tp_dealloc, (void *)__Pyx_Coroutine_dealloc},
  14489. {Py_tp_traverse, (void *)__Pyx_Coroutine_traverse},
  14490. {Py_tp_iter, (void *)PyObject_SelfIter},
  14491. {Py_tp_iternext, (void *)__Pyx_Generator_Next},
  14492. {Py_tp_methods, (void *)__pyx_Generator_methods},
  14493. {Py_tp_members, (void *)__pyx_Generator_memberlist},
  14494. {Py_tp_getset, (void *)__pyx_Generator_getsets},
  14495. {Py_tp_getattro, (void *) PyObject_GenericGetAttr},
  14496. #if CYTHON_USE_TP_FINALIZE
  14497. {Py_tp_finalize, (void *)__Pyx_Coroutine_del},
  14498. #endif
  14499. #if __PYX_HAS_PY_AM_SEND == 1
  14500. {Py_am_send, (void *)__Pyx_Coroutine_AmSend},
  14501. #endif
  14502. {0, 0},
  14503. };
  14504. static PyType_Spec __pyx_GeneratorType_spec = {
  14505. __PYX_TYPE_MODULE_PREFIX "generator",
  14506. sizeof(__pyx_CoroutineObject),
  14507. 0,
  14508. #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14509. Py_TPFLAGS_MANAGED_WEAKREF |
  14510. #endif
  14511. Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
  14512. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | __Pyx_TPFLAGS_HAVE_AM_SEND,
  14513. __pyx_GeneratorType_slots
  14514. };
  14515. #if __PYX_HAS_PY_AM_SEND == 2
  14516. static __Pyx_PyAsyncMethodsStruct __pyx_Generator_as_async;
  14517. #endif
  14518. static int __pyx_Generator_init(PyObject *module) {
  14519. __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
  14520. mstate->__pyx_GeneratorType = __Pyx_FetchCommonTypeFromSpec(
  14521. mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_GeneratorType_spec, NULL);
  14522. if (unlikely(!mstate->__pyx_GeneratorType)) {
  14523. return -1;
  14524. }
  14525. #if __PYX_HAS_PY_AM_SEND == 2
  14526. __Pyx_SetBackportTypeAmSend(mstate->__pyx_GeneratorType, &__pyx_Generator_as_async, &__Pyx_Coroutine_AmSend);
  14527. #endif
  14528. return 0;
  14529. }
  14530. static PyObject *__Pyx_Generator_GetInlinedResult(PyObject *self) {
  14531. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  14532. PyObject *retval = NULL;
  14533. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  14534. return __Pyx_Coroutine_AlreadyRunningError(gen);
  14535. }
  14536. __Pyx_PySendResult result = __Pyx_Coroutine_SendEx(gen, Py_None, &retval, 0);
  14537. __Pyx_Coroutine_unset_is_running(gen);
  14538. (void) result;
  14539. assert (result == PYGEN_RETURN || result == PYGEN_ERROR);
  14540. assert ((result == PYGEN_RETURN && retval != NULL) || (result == PYGEN_ERROR && retval == NULL));
  14541. return retval;
  14542. }
  14543. /* CheckBinaryVersion */
  14544. static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) {
  14545. const unsigned long MAJOR_MINOR = 0xFFFF0000UL;
  14546. if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR))
  14547. return 0;
  14548. if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR)))
  14549. return 1;
  14550. {
  14551. char message[200];
  14552. PyOS_snprintf(message, sizeof(message),
  14553. "compile time Python version %d.%d "
  14554. "of module '%.100s' "
  14555. "%s "
  14556. "runtime version %d.%d",
  14557. (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF),
  14558. __Pyx_MODULE_NAME,
  14559. (allow_newer) ? "was newer than" : "does not match",
  14560. (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF)
  14561. );
  14562. return PyErr_WarnEx(NULL, message, 1);
  14563. }
  14564. }
  14565. /* NewCodeObj */
  14566. #if CYTHON_COMPILING_IN_LIMITED_API
  14567. static PyObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
  14568. PyObject *code, PyObject *c, PyObject* n, PyObject *v,
  14569. PyObject *fv, PyObject *cell, PyObject* fn,
  14570. PyObject *name, int fline, PyObject *lnos) {
  14571. PyObject *exception_table = NULL;
  14572. PyObject *types_module=NULL, *code_type=NULL, *result=NULL;
  14573. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  14574. PyObject *version_info;
  14575. PyObject *py_minor_version = NULL;
  14576. #endif
  14577. long minor_version = 0;
  14578. PyObject *type, *value, *traceback;
  14579. PyErr_Fetch(&type, &value, &traceback);
  14580. #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
  14581. minor_version = 11;
  14582. #else
  14583. if (!(version_info = PySys_GetObject("version_info"))) goto end;
  14584. if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end;
  14585. minor_version = PyLong_AsLong(py_minor_version);
  14586. Py_DECREF(py_minor_version);
  14587. if (minor_version == -1 && PyErr_Occurred()) goto end;
  14588. #endif
  14589. if (!(types_module = PyImport_ImportModule("types"))) goto end;
  14590. if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end;
  14591. if (minor_version <= 7) {
  14592. (void)p;
  14593. result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOOO", a, k, l, s, f, code,
  14594. c, n, v, fn, name, fline, lnos, fv, cell);
  14595. } else if (minor_version <= 10) {
  14596. result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOOO", a,p, k, l, s, f, code,
  14597. c, n, v, fn, name, fline, lnos, fv, cell);
  14598. } else {
  14599. if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end;
  14600. result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOOOO", a,p, k, l, s, f, code,
  14601. c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell);
  14602. }
  14603. end:
  14604. Py_XDECREF(code_type);
  14605. Py_XDECREF(exception_table);
  14606. Py_XDECREF(types_module);
  14607. if (type) {
  14608. PyErr_Restore(type, value, traceback);
  14609. }
  14610. return result;
  14611. }
  14612. #elif PY_VERSION_HEX >= 0x030B0000
  14613. static PyCodeObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
  14614. PyObject *code, PyObject *c, PyObject* n, PyObject *v,
  14615. PyObject *fv, PyObject *cell, PyObject* fn,
  14616. PyObject *name, int fline, PyObject *lnos) {
  14617. PyCodeObject *result;
  14618. result =
  14619. #if PY_VERSION_HEX >= 0x030C0000
  14620. PyUnstable_Code_NewWithPosOnlyArgs
  14621. #else
  14622. PyCode_NewWithPosOnlyArgs
  14623. #endif
  14624. (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, __pyx_mstate_global->__pyx_empty_bytes);
  14625. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030c00A1
  14626. if (likely(result))
  14627. result->_co_firsttraceable = 0;
  14628. #endif
  14629. return result;
  14630. }
  14631. #elif !CYTHON_COMPILING_IN_PYPY
  14632. #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  14633. PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  14634. #else
  14635. #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  14636. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  14637. #endif
  14638. static PyObject* __Pyx_PyCode_New(
  14639. const __Pyx_PyCode_New_function_description descr,
  14640. PyObject * const *varnames,
  14641. PyObject *filename,
  14642. PyObject *funcname,
  14643. PyObject *line_table,
  14644. PyObject *tuple_dedup_map
  14645. ) {
  14646. PyObject *code_obj = NULL, *varnames_tuple_dedup = NULL, *code_bytes = NULL;
  14647. Py_ssize_t var_count = (Py_ssize_t) descr.nlocals;
  14648. PyObject *varnames_tuple = PyTuple_New(var_count);
  14649. if (unlikely(!varnames_tuple)) return NULL;
  14650. for (Py_ssize_t i=0; i < var_count; i++) {
  14651. Py_INCREF(varnames[i]);
  14652. if (__Pyx_PyTuple_SET_ITEM(varnames_tuple, i, varnames[i]) != (0)) goto done;
  14653. }
  14654. #if CYTHON_COMPILING_IN_LIMITED_API
  14655. varnames_tuple_dedup = PyDict_GetItem(tuple_dedup_map, varnames_tuple);
  14656. if (!varnames_tuple_dedup) {
  14657. if (unlikely(PyDict_SetItem(tuple_dedup_map, varnames_tuple, varnames_tuple) < 0)) goto done;
  14658. varnames_tuple_dedup = varnames_tuple;
  14659. }
  14660. #else
  14661. varnames_tuple_dedup = PyDict_SetDefault(tuple_dedup_map, varnames_tuple, varnames_tuple);
  14662. if (unlikely(!varnames_tuple_dedup)) goto done;
  14663. #endif
  14664. #if CYTHON_AVOID_BORROWED_REFS
  14665. Py_INCREF(varnames_tuple_dedup);
  14666. #endif
  14667. if (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table != NULL && !CYTHON_COMPILING_IN_GRAAL) {
  14668. Py_ssize_t line_table_length = __Pyx_PyBytes_GET_SIZE(line_table);
  14669. #if !CYTHON_ASSUME_SAFE_SIZE
  14670. if (unlikely(line_table_length == -1)) goto done;
  14671. #endif
  14672. Py_ssize_t code_len = (line_table_length * 2 + 4) & ~3LL;
  14673. code_bytes = PyBytes_FromStringAndSize(NULL, code_len);
  14674. if (unlikely(!code_bytes)) goto done;
  14675. char* c_code_bytes = PyBytes_AsString(code_bytes);
  14676. if (unlikely(!c_code_bytes)) goto done;
  14677. memset(c_code_bytes, 0, (size_t) code_len);
  14678. }
  14679. code_obj = (PyObject*) __Pyx__PyCode_New(
  14680. (int) descr.argcount,
  14681. (int) descr.num_posonly_args,
  14682. (int) descr.num_kwonly_args,
  14683. (int) descr.nlocals,
  14684. 0,
  14685. (int) descr.flags,
  14686. code_bytes ? code_bytes : __pyx_mstate_global->__pyx_empty_bytes,
  14687. __pyx_mstate_global->__pyx_empty_tuple,
  14688. __pyx_mstate_global->__pyx_empty_tuple,
  14689. varnames_tuple_dedup,
  14690. __pyx_mstate_global->__pyx_empty_tuple,
  14691. __pyx_mstate_global->__pyx_empty_tuple,
  14692. filename,
  14693. funcname,
  14694. (int) descr.first_line,
  14695. (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table) ? line_table : __pyx_mstate_global->__pyx_empty_bytes
  14696. );
  14697. done:
  14698. Py_XDECREF(code_bytes);
  14699. #if CYTHON_AVOID_BORROWED_REFS
  14700. Py_XDECREF(varnames_tuple_dedup);
  14701. #endif
  14702. Py_DECREF(varnames_tuple);
  14703. return code_obj;
  14704. }
  14705. /* DecompressString */
  14706. static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo) {
  14707. PyObject *module = NULL, *decompress, *compressed_bytes, *decompressed;
  14708. const char* module_name = algo == 3 ? "compression.zstd" : algo == 2 ? "bz2" : "zlib";
  14709. PyObject *methodname = PyUnicode_FromString("decompress");
  14710. if (unlikely(!methodname)) return NULL;
  14711. #if __PYX_LIMITED_VERSION_HEX >= 0x030e0000
  14712. if (algo == 3) {
  14713. PyObject *fromlist = Py_BuildValue("[O]", methodname);
  14714. if (unlikely(!fromlist)) goto bad;
  14715. module = PyImport_ImportModuleLevel("compression.zstd", NULL, NULL, fromlist, 0);
  14716. Py_DECREF(fromlist);
  14717. } else
  14718. #endif
  14719. module = PyImport_ImportModule(module_name);
  14720. if (unlikely(!module)) goto import_failed;
  14721. decompress = PyObject_GetAttr(module, methodname);
  14722. if (unlikely(!decompress)) goto import_failed;
  14723. {
  14724. #ifdef __cplusplus
  14725. char *memview_bytes = const_cast<char*>(s);
  14726. #else
  14727. #if defined(__clang__)
  14728. #pragma clang diagnostic push
  14729. #pragma clang diagnostic ignored "-Wcast-qual"
  14730. #elif !defined(__INTEL_COMPILER) && defined(__GNUC__)
  14731. #pragma GCC diagnostic push
  14732. #pragma GCC diagnostic ignored "-Wcast-qual"
  14733. #endif
  14734. char *memview_bytes = (char*) s;
  14735. #if defined(__clang__)
  14736. #pragma clang diagnostic pop
  14737. #elif !defined(__INTEL_COMPILER) && defined(__GNUC__)
  14738. #pragma GCC diagnostic pop
  14739. #endif
  14740. #endif
  14741. #if CYTHON_COMPILING_IN_LIMITED_API && !defined(PyBUF_READ)
  14742. int memview_flags = 0x100;
  14743. #else
  14744. int memview_flags = PyBUF_READ;
  14745. #endif
  14746. compressed_bytes = PyMemoryView_FromMemory(memview_bytes, length, memview_flags);
  14747. }
  14748. if (unlikely(!compressed_bytes)) {
  14749. Py_DECREF(decompress);
  14750. goto bad;
  14751. }
  14752. decompressed = PyObject_CallFunctionObjArgs(decompress, compressed_bytes, NULL);
  14753. Py_DECREF(compressed_bytes);
  14754. Py_DECREF(decompress);
  14755. Py_DECREF(module);
  14756. Py_DECREF(methodname);
  14757. return decompressed;
  14758. import_failed:
  14759. PyErr_Format(PyExc_ImportError,
  14760. "Failed to import '%.20s.decompress' - cannot initialise module strings. "
  14761. "String compression was configured with the C macro 'CYTHON_COMPRESS_STRINGS=%d'.",
  14762. module_name, algo);
  14763. bad:
  14764. Py_XDECREF(module);
  14765. Py_DECREF(methodname);
  14766. return NULL;
  14767. }
  14768. #include <string.h>
  14769. static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) {
  14770. size_t len = strlen(s);
  14771. if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) {
  14772. PyErr_SetString(PyExc_OverflowError, "byte string is too long");
  14773. return -1;
  14774. }
  14775. return (Py_ssize_t) len;
  14776. }
  14777. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  14778. Py_ssize_t len = __Pyx_ssize_strlen(c_str);
  14779. if (unlikely(len < 0)) return NULL;
  14780. return __Pyx_PyUnicode_FromStringAndSize(c_str, len);
  14781. }
  14782. static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) {
  14783. Py_ssize_t len = __Pyx_ssize_strlen(c_str);
  14784. if (unlikely(len < 0)) return NULL;
  14785. return PyByteArray_FromStringAndSize(c_str, len);
  14786. }
  14787. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  14788. Py_ssize_t ignore;
  14789. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  14790. }
  14791. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
  14792. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  14793. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  14794. #if CYTHON_COMPILING_IN_LIMITED_API
  14795. {
  14796. const char* result;
  14797. Py_ssize_t unicode_length;
  14798. CYTHON_MAYBE_UNUSED_VAR(unicode_length); // only for __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  14799. #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
  14800. if (unlikely(PyArg_Parse(o, "s#", &result, length) < 0)) return NULL;
  14801. #else
  14802. result = PyUnicode_AsUTF8AndSize(o, length);
  14803. #endif
  14804. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  14805. unicode_length = PyUnicode_GetLength(o);
  14806. if (unlikely(unicode_length < 0)) return NULL;
  14807. if (unlikely(unicode_length != *length)) {
  14808. PyUnicode_AsASCIIString(o);
  14809. return NULL;
  14810. }
  14811. #endif
  14812. return result;
  14813. }
  14814. #else
  14815. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  14816. if (likely(PyUnicode_IS_ASCII(o))) {
  14817. *length = PyUnicode_GET_LENGTH(o);
  14818. return PyUnicode_AsUTF8(o);
  14819. } else {
  14820. PyUnicode_AsASCIIString(o);
  14821. return NULL;
  14822. }
  14823. #else
  14824. return PyUnicode_AsUTF8AndSize(o, length);
  14825. #endif
  14826. #endif
  14827. }
  14828. #endif
  14829. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  14830. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
  14831. if (PyUnicode_Check(o)) {
  14832. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  14833. } else
  14834. #endif
  14835. if (PyByteArray_Check(o)) {
  14836. #if (CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS) || (CYTHON_COMPILING_IN_PYPY && (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)))
  14837. *length = PyByteArray_GET_SIZE(o);
  14838. return PyByteArray_AS_STRING(o);
  14839. #else
  14840. *length = PyByteArray_Size(o);
  14841. if (*length == -1) return NULL;
  14842. return PyByteArray_AsString(o);
  14843. #endif
  14844. } else
  14845. {
  14846. char* result;
  14847. int r = PyBytes_AsStringAndSize(o, &result, length);
  14848. if (unlikely(r < 0)) {
  14849. return NULL;
  14850. } else {
  14851. return result;
  14852. }
  14853. }
  14854. }
  14855. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  14856. int is_true = x == Py_True;
  14857. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  14858. else return PyObject_IsTrue(x);
  14859. }
  14860. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
  14861. int retval;
  14862. if (unlikely(!x)) return -1;
  14863. retval = __Pyx_PyObject_IsTrue(x);
  14864. Py_DECREF(x);
  14865. return retval;
  14866. }
  14867. static PyObject* __Pyx_PyNumber_LongWrongResultType(PyObject* result) {
  14868. __Pyx_TypeName result_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(result));
  14869. if (PyLong_Check(result)) {
  14870. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  14871. "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). "
  14872. "The ability to return an instance of a strict subclass of int is deprecated, "
  14873. "and may be removed in a future version of Python.",
  14874. result_type_name)) {
  14875. __Pyx_DECREF_TypeName(result_type_name);
  14876. Py_DECREF(result);
  14877. return NULL;
  14878. }
  14879. __Pyx_DECREF_TypeName(result_type_name);
  14880. return result;
  14881. }
  14882. PyErr_Format(PyExc_TypeError,
  14883. "__int__ returned non-int (type " __Pyx_FMT_TYPENAME ")",
  14884. result_type_name);
  14885. __Pyx_DECREF_TypeName(result_type_name);
  14886. Py_DECREF(result);
  14887. return NULL;
  14888. }
  14889. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x) {
  14890. #if CYTHON_USE_TYPE_SLOTS
  14891. PyNumberMethods *m;
  14892. #endif
  14893. PyObject *res = NULL;
  14894. if (likely(PyLong_Check(x)))
  14895. return __Pyx_NewRef(x);
  14896. #if CYTHON_USE_TYPE_SLOTS
  14897. m = Py_TYPE(x)->tp_as_number;
  14898. if (likely(m && m->nb_int)) {
  14899. res = m->nb_int(x);
  14900. }
  14901. #else
  14902. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  14903. res = PyNumber_Long(x);
  14904. }
  14905. #endif
  14906. if (likely(res)) {
  14907. if (unlikely(!PyLong_CheckExact(res))) {
  14908. return __Pyx_PyNumber_LongWrongResultType(res);
  14909. }
  14910. }
  14911. else if (!PyErr_Occurred()) {
  14912. PyErr_SetString(PyExc_TypeError,
  14913. "an integer is required");
  14914. }
  14915. return res;
  14916. }
  14917. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  14918. Py_ssize_t ival;
  14919. PyObject *x;
  14920. if (likely(PyLong_CheckExact(b))) {
  14921. #if CYTHON_USE_PYLONG_INTERNALS
  14922. if (likely(__Pyx_PyLong_IsCompact(b))) {
  14923. return __Pyx_PyLong_CompactValue(b);
  14924. } else {
  14925. const digit* digits = __Pyx_PyLong_Digits(b);
  14926. const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b);
  14927. switch (size) {
  14928. case 2:
  14929. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  14930. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14931. }
  14932. break;
  14933. case -2:
  14934. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  14935. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14936. }
  14937. break;
  14938. case 3:
  14939. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  14940. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14941. }
  14942. break;
  14943. case -3:
  14944. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  14945. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14946. }
  14947. break;
  14948. case 4:
  14949. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  14950. 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]));
  14951. }
  14952. break;
  14953. case -4:
  14954. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  14955. 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]));
  14956. }
  14957. break;
  14958. }
  14959. }
  14960. #endif
  14961. return PyLong_AsSsize_t(b);
  14962. }
  14963. x = PyNumber_Index(b);
  14964. if (!x) return -1;
  14965. ival = PyLong_AsSsize_t(x);
  14966. Py_DECREF(x);
  14967. return ival;
  14968. }
  14969. static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
  14970. if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
  14971. return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
  14972. } else {
  14973. Py_ssize_t ival;
  14974. PyObject *x;
  14975. x = PyNumber_Index(o);
  14976. if (!x) return -1;
  14977. ival = PyLong_AsLong(x);
  14978. Py_DECREF(x);
  14979. return ival;
  14980. }
  14981. }
  14982. static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b) {
  14983. CYTHON_UNUSED_VAR(b);
  14984. return __Pyx_NewRef(Py_None);
  14985. }
  14986. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  14987. return __Pyx_NewRef(b ? Py_True: Py_False);
  14988. }
  14989. static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t ival) {
  14990. return PyLong_FromSize_t(ival);
  14991. }
  14992. /* MultiPhaseInitModuleState */
  14993. #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
  14994. #ifndef CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  14995. #if (CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000)
  14996. #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 1
  14997. #else
  14998. #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 0
  14999. #endif
  15000. #endif
  15001. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE && !CYTHON_ATOMICS
  15002. #error "Module state with PEP489 requires atomics. Currently that's one of\
  15003. C11, C++11, gcc atomic intrinsics or MSVC atomic intrinsics"
  15004. #endif
  15005. #if !CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15006. #define __Pyx_ModuleStateLookup_Lock()
  15007. #define __Pyx_ModuleStateLookup_Unlock()
  15008. #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
  15009. static PyMutex __Pyx_ModuleStateLookup_mutex = {0};
  15010. #define __Pyx_ModuleStateLookup_Lock() PyMutex_Lock(&__Pyx_ModuleStateLookup_mutex)
  15011. #define __Pyx_ModuleStateLookup_Unlock() PyMutex_Unlock(&__Pyx_ModuleStateLookup_mutex)
  15012. #elif defined(__cplusplus) && __cplusplus >= 201103L
  15013. #include <mutex>
  15014. static std::mutex __Pyx_ModuleStateLookup_mutex;
  15015. #define __Pyx_ModuleStateLookup_Lock() __Pyx_ModuleStateLookup_mutex.lock()
  15016. #define __Pyx_ModuleStateLookup_Unlock() __Pyx_ModuleStateLookup_mutex.unlock()
  15017. #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201112L) && !defined(__STDC_NO_THREADS__)
  15018. #include <threads.h>
  15019. static mtx_t __Pyx_ModuleStateLookup_mutex;
  15020. static once_flag __Pyx_ModuleStateLookup_mutex_once_flag = ONCE_FLAG_INIT;
  15021. static void __Pyx_ModuleStateLookup_initialize_mutex(void) {
  15022. mtx_init(&__Pyx_ModuleStateLookup_mutex, mtx_plain);
  15023. }
  15024. #define __Pyx_ModuleStateLookup_Lock()\
  15025. call_once(&__Pyx_ModuleStateLookup_mutex_once_flag, __Pyx_ModuleStateLookup_initialize_mutex);\
  15026. mtx_lock(&__Pyx_ModuleStateLookup_mutex)
  15027. #define __Pyx_ModuleStateLookup_Unlock() mtx_unlock(&__Pyx_ModuleStateLookup_mutex)
  15028. #elif defined(HAVE_PTHREAD_H)
  15029. #include <pthread.h>
  15030. static pthread_mutex_t __Pyx_ModuleStateLookup_mutex = PTHREAD_MUTEX_INITIALIZER;
  15031. #define __Pyx_ModuleStateLookup_Lock() pthread_mutex_lock(&__Pyx_ModuleStateLookup_mutex)
  15032. #define __Pyx_ModuleStateLookup_Unlock() pthread_mutex_unlock(&__Pyx_ModuleStateLookup_mutex)
  15033. #elif defined(_WIN32)
  15034. #include <Windows.h> // synchapi.h on its own doesn't work
  15035. static SRWLOCK __Pyx_ModuleStateLookup_mutex = SRWLOCK_INIT;
  15036. #define __Pyx_ModuleStateLookup_Lock() AcquireSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
  15037. #define __Pyx_ModuleStateLookup_Unlock() ReleaseSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
  15038. #else
  15039. #error "No suitable lock available for CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE.\
  15040. Requires C standard >= C11, or C++ standard >= C++11,\
  15041. or pthreads, or the Windows 32 API, or Python >= 3.13."
  15042. #endif
  15043. typedef struct {
  15044. int64_t id;
  15045. PyObject *module;
  15046. } __Pyx_InterpreterIdAndModule;
  15047. typedef struct {
  15048. char interpreter_id_as_index;
  15049. Py_ssize_t count;
  15050. Py_ssize_t allocated;
  15051. __Pyx_InterpreterIdAndModule table[1];
  15052. } __Pyx_ModuleStateLookupData;
  15053. #define __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE 32
  15054. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15055. static __pyx_atomic_int_type __Pyx_ModuleStateLookup_read_counter = 0;
  15056. #endif
  15057. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15058. static __pyx_atomic_ptr_type __Pyx_ModuleStateLookup_data = 0;
  15059. #else
  15060. static __Pyx_ModuleStateLookupData* __Pyx_ModuleStateLookup_data = NULL;
  15061. #endif
  15062. static __Pyx_InterpreterIdAndModule* __Pyx_State_FindModuleStateLookupTableLowerBound(
  15063. __Pyx_InterpreterIdAndModule* table,
  15064. Py_ssize_t count,
  15065. int64_t interpreterId) {
  15066. __Pyx_InterpreterIdAndModule* begin = table;
  15067. __Pyx_InterpreterIdAndModule* end = begin + count;
  15068. if (begin->id == interpreterId) {
  15069. return begin;
  15070. }
  15071. while ((end - begin) > __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
  15072. __Pyx_InterpreterIdAndModule* halfway = begin + (end - begin)/2;
  15073. if (halfway->id == interpreterId) {
  15074. return halfway;
  15075. }
  15076. if (halfway->id < interpreterId) {
  15077. begin = halfway;
  15078. } else {
  15079. end = halfway;
  15080. }
  15081. }
  15082. for (; begin < end; ++begin) {
  15083. if (begin->id >= interpreterId) return begin;
  15084. }
  15085. return begin;
  15086. }
  15087. static PyObject *__Pyx_State_FindModule(CYTHON_UNUSED void* dummy) {
  15088. int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
  15089. if (interpreter_id == -1) return NULL;
  15090. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15091. __Pyx_ModuleStateLookupData* data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
  15092. {
  15093. __pyx_atomic_incr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
  15094. if (likely(data)) {
  15095. __Pyx_ModuleStateLookupData* new_data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_acquire(&__Pyx_ModuleStateLookup_data);
  15096. if (likely(data == new_data)) {
  15097. goto read_finished;
  15098. }
  15099. }
  15100. __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
  15101. __Pyx_ModuleStateLookup_Lock();
  15102. __pyx_atomic_incr_relaxed(&__Pyx_ModuleStateLookup_read_counter);
  15103. data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
  15104. __Pyx_ModuleStateLookup_Unlock();
  15105. }
  15106. read_finished:;
  15107. #else
  15108. __Pyx_ModuleStateLookupData* data = __Pyx_ModuleStateLookup_data;
  15109. #endif
  15110. __Pyx_InterpreterIdAndModule* found = NULL;
  15111. if (unlikely(!data)) goto end;
  15112. if (data->interpreter_id_as_index) {
  15113. if (interpreter_id < data->count) {
  15114. found = data->table+interpreter_id;
  15115. }
  15116. } else {
  15117. found = __Pyx_State_FindModuleStateLookupTableLowerBound(
  15118. data->table, data->count, interpreter_id);
  15119. }
  15120. end:
  15121. {
  15122. PyObject *result=NULL;
  15123. if (found && found->id == interpreter_id) {
  15124. result = found->module;
  15125. }
  15126. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15127. __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
  15128. #endif
  15129. return result;
  15130. }
  15131. }
  15132. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15133. static void __Pyx_ModuleStateLookup_wait_until_no_readers(void) {
  15134. while (__pyx_atomic_load(&__Pyx_ModuleStateLookup_read_counter) != 0);
  15135. }
  15136. #else
  15137. #define __Pyx_ModuleStateLookup_wait_until_no_readers()
  15138. #endif
  15139. static int __Pyx_State_AddModuleInterpIdAsIndex(__Pyx_ModuleStateLookupData **old_data, PyObject* module, int64_t interpreter_id) {
  15140. Py_ssize_t to_allocate = (*old_data)->allocated;
  15141. while (to_allocate <= interpreter_id) {
  15142. if (to_allocate == 0) to_allocate = 1;
  15143. else to_allocate *= 2;
  15144. }
  15145. __Pyx_ModuleStateLookupData *new_data = *old_data;
  15146. if (to_allocate != (*old_data)->allocated) {
  15147. new_data = (__Pyx_ModuleStateLookupData *)realloc(
  15148. *old_data,
  15149. sizeof(__Pyx_ModuleStateLookupData)+(to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
  15150. if (!new_data) {
  15151. PyErr_NoMemory();
  15152. return -1;
  15153. }
  15154. for (Py_ssize_t i = new_data->allocated; i < to_allocate; ++i) {
  15155. new_data->table[i].id = i;
  15156. new_data->table[i].module = NULL;
  15157. }
  15158. new_data->allocated = to_allocate;
  15159. }
  15160. new_data->table[interpreter_id].module = module;
  15161. if (new_data->count < interpreter_id+1) {
  15162. new_data->count = interpreter_id+1;
  15163. }
  15164. *old_data = new_data;
  15165. return 0;
  15166. }
  15167. static void __Pyx_State_ConvertFromInterpIdAsIndex(__Pyx_ModuleStateLookupData *data) {
  15168. __Pyx_InterpreterIdAndModule *read = data->table;
  15169. __Pyx_InterpreterIdAndModule *write = data->table;
  15170. __Pyx_InterpreterIdAndModule *end = read + data->count;
  15171. for (; read<end; ++read) {
  15172. if (read->module) {
  15173. write->id = read->id;
  15174. write->module = read->module;
  15175. ++write;
  15176. }
  15177. }
  15178. data->count = write - data->table;
  15179. for (; write<end; ++write) {
  15180. write->id = 0;
  15181. write->module = NULL;
  15182. }
  15183. data->interpreter_id_as_index = 0;
  15184. }
  15185. static int __Pyx_State_AddModule(PyObject* module, CYTHON_UNUSED void* dummy) {
  15186. int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
  15187. if (interpreter_id == -1) return -1;
  15188. int result = 0;
  15189. __Pyx_ModuleStateLookup_Lock();
  15190. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15191. __Pyx_ModuleStateLookupData *old_data = (__Pyx_ModuleStateLookupData *)
  15192. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
  15193. #else
  15194. __Pyx_ModuleStateLookupData *old_data = __Pyx_ModuleStateLookup_data;
  15195. #endif
  15196. __Pyx_ModuleStateLookupData *new_data = old_data;
  15197. if (!new_data) {
  15198. new_data = (__Pyx_ModuleStateLookupData *)calloc(1, sizeof(__Pyx_ModuleStateLookupData));
  15199. if (!new_data) {
  15200. result = -1;
  15201. PyErr_NoMemory();
  15202. goto end;
  15203. }
  15204. new_data->allocated = 1;
  15205. new_data->interpreter_id_as_index = 1;
  15206. }
  15207. __Pyx_ModuleStateLookup_wait_until_no_readers();
  15208. if (new_data->interpreter_id_as_index) {
  15209. if (interpreter_id < __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
  15210. result = __Pyx_State_AddModuleInterpIdAsIndex(&new_data, module, interpreter_id);
  15211. goto end;
  15212. }
  15213. __Pyx_State_ConvertFromInterpIdAsIndex(new_data);
  15214. }
  15215. {
  15216. Py_ssize_t insert_at = 0;
  15217. {
  15218. __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
  15219. new_data->table, new_data->count, interpreter_id);
  15220. assert(lower_bound);
  15221. insert_at = lower_bound - new_data->table;
  15222. if (unlikely(insert_at < new_data->count && lower_bound->id == interpreter_id)) {
  15223. lower_bound->module = module;
  15224. goto end; // already in table, nothing more to do
  15225. }
  15226. }
  15227. if (new_data->count+1 >= new_data->allocated) {
  15228. Py_ssize_t to_allocate = (new_data->count+1)*2;
  15229. new_data =
  15230. (__Pyx_ModuleStateLookupData*)realloc(
  15231. new_data,
  15232. sizeof(__Pyx_ModuleStateLookupData) +
  15233. (to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
  15234. if (!new_data) {
  15235. result = -1;
  15236. new_data = old_data;
  15237. PyErr_NoMemory();
  15238. goto end;
  15239. }
  15240. new_data->allocated = to_allocate;
  15241. }
  15242. ++new_data->count;
  15243. int64_t last_id = interpreter_id;
  15244. PyObject *last_module = module;
  15245. for (Py_ssize_t i=insert_at; i<new_data->count; ++i) {
  15246. int64_t current_id = new_data->table[i].id;
  15247. new_data->table[i].id = last_id;
  15248. last_id = current_id;
  15249. PyObject *current_module = new_data->table[i].module;
  15250. new_data->table[i].module = last_module;
  15251. last_module = current_module;
  15252. }
  15253. }
  15254. end:
  15255. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15256. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, new_data);
  15257. #else
  15258. __Pyx_ModuleStateLookup_data = new_data;
  15259. #endif
  15260. __Pyx_ModuleStateLookup_Unlock();
  15261. return result;
  15262. }
  15263. static int __Pyx_State_RemoveModule(CYTHON_UNUSED void* dummy) {
  15264. int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
  15265. if (interpreter_id == -1) return -1;
  15266. __Pyx_ModuleStateLookup_Lock();
  15267. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15268. __Pyx_ModuleStateLookupData *data = (__Pyx_ModuleStateLookupData *)
  15269. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
  15270. #else
  15271. __Pyx_ModuleStateLookupData *data = __Pyx_ModuleStateLookup_data;
  15272. #endif
  15273. if (data->interpreter_id_as_index) {
  15274. if (interpreter_id < data->count) {
  15275. data->table[interpreter_id].module = NULL;
  15276. }
  15277. goto done;
  15278. }
  15279. {
  15280. __Pyx_ModuleStateLookup_wait_until_no_readers();
  15281. __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
  15282. data->table, data->count, interpreter_id);
  15283. if (!lower_bound) goto done;
  15284. if (lower_bound->id != interpreter_id) goto done;
  15285. __Pyx_InterpreterIdAndModule *end = data->table+data->count;
  15286. for (;lower_bound<end-1; ++lower_bound) {
  15287. lower_bound->id = (lower_bound+1)->id;
  15288. lower_bound->module = (lower_bound+1)->module;
  15289. }
  15290. }
  15291. --data->count;
  15292. if (data->count == 0) {
  15293. free(data);
  15294. data = NULL;
  15295. }
  15296. done:
  15297. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15298. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, data);
  15299. #else
  15300. __Pyx_ModuleStateLookup_data = data;
  15301. #endif
  15302. __Pyx_ModuleStateLookup_Unlock();
  15303. return 0;
  15304. }
  15305. #endif
  15306. /* #### Code section: utility_code_pragmas_end ### */
  15307. #ifdef _MSC_VER
  15308. #pragma warning( pop )
  15309. #endif
  15310. /* #### Code section: end ### */
  15311. #endif /* Py_PYTHON_H */