pocketpy_bindings_generated.dart 110 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381
  1. // ignore_for_file: always_specify_types
  2. // ignore_for_file: camel_case_types
  3. // ignore_for_file: non_constant_identifier_names
  4. // AUTO GENERATED FILE, DO NOT EDIT.
  5. //
  6. // Generated by `package:ffigen`.
  7. // ignore_for_file: type=lint
  8. import 'dart:ffi' as ffi;
  9. /// Bindings for `src/pocketpy.h`.
  10. ///
  11. /// Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`.
  12. ///
  13. class PocketpyBindings {
  14. /// Holds the symbol lookup function.
  15. final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
  16. _lookup;
  17. /// The symbols are looked up in [dynamicLibrary].
  18. PocketpyBindings(ffi.DynamicLibrary dynamicLibrary)
  19. : _lookup = dynamicLibrary.lookup;
  20. /// The symbols are looked up with [lookup].
  21. PocketpyBindings.fromLookup(
  22. ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
  23. lookup)
  24. : _lookup = lookup;
  25. /// Initialize pocketpy and the default VM.
  26. void py_initialize() {
  27. return _py_initialize();
  28. }
  29. late final _py_initializePtr =
  30. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_initialize');
  31. late final _py_initialize = _py_initializePtr.asFunction<void Function()>();
  32. /// Finalize pocketpy and free all VMs. This opearation is irreversible.
  33. /// After this call, you cannot use any function from this header anymore.
  34. void py_finalize() {
  35. return _py_finalize();
  36. }
  37. late final _py_finalizePtr =
  38. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_finalize');
  39. late final _py_finalize = _py_finalizePtr.asFunction<void Function()>();
  40. /// Get the current VM index.
  41. int py_currentvm() {
  42. return _py_currentvm();
  43. }
  44. late final _py_currentvmPtr =
  45. _lookup<ffi.NativeFunction<ffi.Int Function()>>('py_currentvm');
  46. late final _py_currentvm = _py_currentvmPtr.asFunction<int Function()>();
  47. /// Switch to a VM.
  48. /// @param index index of the VM ranging from 0 to 16 (exclusive). `0` is the default VM.
  49. void py_switchvm(
  50. int index,
  51. ) {
  52. return _py_switchvm(
  53. index,
  54. );
  55. }
  56. late final _py_switchvmPtr =
  57. _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int)>>('py_switchvm');
  58. late final _py_switchvm = _py_switchvmPtr.asFunction<void Function(int)>();
  59. /// Reset the current VM.
  60. void py_resetvm() {
  61. return _py_resetvm();
  62. }
  63. late final _py_resetvmPtr =
  64. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_resetvm');
  65. late final _py_resetvm = _py_resetvmPtr.asFunction<void Function()>();
  66. /// Reset All VMs.
  67. void py_resetallvm() {
  68. return _py_resetallvm();
  69. }
  70. late final _py_resetallvmPtr =
  71. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_resetallvm');
  72. late final _py_resetallvm = _py_resetallvmPtr.asFunction<void Function()>();
  73. /// Get the current VM context. This is used for user-defined data.
  74. ffi.Pointer<ffi.Void> py_getvmctx() {
  75. return _py_getvmctx();
  76. }
  77. late final _py_getvmctxPtr =
  78. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Void> Function()>>(
  79. 'py_getvmctx');
  80. late final _py_getvmctx =
  81. _py_getvmctxPtr.asFunction<ffi.Pointer<ffi.Void> Function()>();
  82. /// Set the current VM context. This is used for user-defined data.
  83. void py_setvmctx(
  84. ffi.Pointer<ffi.Void> ctx,
  85. ) {
  86. return _py_setvmctx(
  87. ctx,
  88. );
  89. }
  90. late final _py_setvmctxPtr =
  91. _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>(
  92. 'py_setvmctx');
  93. late final _py_setvmctx =
  94. _py_setvmctxPtr.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
  95. /// Setup the callbacks for the current VM.
  96. ffi.Pointer<py_Callbacks> py_callbacks() {
  97. return _py_callbacks();
  98. }
  99. late final _py_callbacksPtr =
  100. _lookup<ffi.NativeFunction<ffi.Pointer<py_Callbacks> Function()>>(
  101. 'py_callbacks');
  102. late final _py_callbacks =
  103. _py_callbacksPtr.asFunction<ffi.Pointer<py_Callbacks> Function()>();
  104. /// Setup the application callbacks
  105. ffi.Pointer<py_AppCallbacks> py_appcallbacks() {
  106. return _py_appcallbacks();
  107. }
  108. late final _py_appcallbacksPtr =
  109. _lookup<ffi.NativeFunction<ffi.Pointer<py_AppCallbacks> Function()>>(
  110. 'py_appcallbacks');
  111. late final _py_appcallbacks =
  112. _py_appcallbacksPtr.asFunction<ffi.Pointer<py_AppCallbacks> Function()>();
  113. /// Set `sys.argv`. Used for storing command-line arguments.
  114. void py_sys_setargv(
  115. int argc,
  116. ffi.Pointer<ffi.Pointer<ffi.Char>> argv,
  117. ) {
  118. return _py_sys_setargv(
  119. argc,
  120. argv,
  121. );
  122. }
  123. late final _py_sys_setargvPtr = _lookup<
  124. ffi.NativeFunction<
  125. ffi.Void Function(
  126. ffi.Int, ffi.Pointer<ffi.Pointer<ffi.Char>>)>>('py_sys_setargv');
  127. late final _py_sys_setargv = _py_sys_setargvPtr
  128. .asFunction<void Function(int, ffi.Pointer<ffi.Pointer<ffi.Char>>)>();
  129. /// Set the trace function for the current VM.
  130. void py_sys_settrace(
  131. py_TraceFunc func,
  132. bool reset,
  133. ) {
  134. return _py_sys_settrace(
  135. func,
  136. reset,
  137. );
  138. }
  139. late final _py_sys_settracePtr =
  140. _lookup<ffi.NativeFunction<ffi.Void Function(py_TraceFunc, ffi.Bool)>>(
  141. 'py_sys_settrace');
  142. late final _py_sys_settrace =
  143. _py_sys_settracePtr.asFunction<void Function(py_TraceFunc, bool)>();
  144. /// Invoke the garbage collector.
  145. int py_gc_collect() {
  146. return _py_gc_collect();
  147. }
  148. late final _py_gc_collectPtr =
  149. _lookup<ffi.NativeFunction<ffi.Int Function()>>('py_gc_collect');
  150. late final _py_gc_collect = _py_gc_collectPtr.asFunction<int Function()>();
  151. /// Wrapper for `PK_MALLOC(size)`.
  152. ffi.Pointer<ffi.Void> py_malloc(
  153. int size,
  154. ) {
  155. return _py_malloc(
  156. size,
  157. );
  158. }
  159. late final _py_mallocPtr =
  160. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Void> Function(ffi.Size)>>(
  161. 'py_malloc');
  162. late final _py_malloc =
  163. _py_mallocPtr.asFunction<ffi.Pointer<ffi.Void> Function(int)>();
  164. /// Wrapper for `PK_REALLOC(ptr, size)`.
  165. ffi.Pointer<ffi.Void> py_realloc(
  166. ffi.Pointer<ffi.Void> ptr,
  167. int size,
  168. ) {
  169. return _py_realloc(
  170. ptr,
  171. size,
  172. );
  173. }
  174. late final _py_reallocPtr = _lookup<
  175. ffi.NativeFunction<
  176. ffi.Pointer<ffi.Void> Function(
  177. ffi.Pointer<ffi.Void>, ffi.Size)>>('py_realloc');
  178. late final _py_realloc = _py_reallocPtr
  179. .asFunction<ffi.Pointer<ffi.Void> Function(ffi.Pointer<ffi.Void>, int)>();
  180. /// Wrapper for `PK_FREE(ptr)`.
  181. void py_free(
  182. ffi.Pointer<ffi.Void> ptr,
  183. ) {
  184. return _py_free(
  185. ptr,
  186. );
  187. }
  188. late final _py_freePtr =
  189. _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>(
  190. 'py_free');
  191. late final _py_free =
  192. _py_freePtr.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
  193. /// A shorthand for `True`.
  194. py_GlobalRef py_True() {
  195. return _py_True();
  196. }
  197. late final _py_TruePtr =
  198. _lookup<ffi.NativeFunction<py_GlobalRef Function()>>('py_True');
  199. late final _py_True = _py_TruePtr.asFunction<py_GlobalRef Function()>();
  200. /// A shorthand for `False`.
  201. py_GlobalRef py_False() {
  202. return _py_False();
  203. }
  204. late final _py_FalsePtr =
  205. _lookup<ffi.NativeFunction<py_GlobalRef Function()>>('py_False');
  206. late final _py_False = _py_FalsePtr.asFunction<py_GlobalRef Function()>();
  207. /// A shorthand for `None`.
  208. py_GlobalRef py_None() {
  209. return _py_None();
  210. }
  211. late final _py_NonePtr =
  212. _lookup<ffi.NativeFunction<py_GlobalRef Function()>>('py_None');
  213. late final _py_None = _py_NonePtr.asFunction<py_GlobalRef Function()>();
  214. /// A shorthand for `nil`. `nil` is not a valid python object.
  215. py_GlobalRef py_NIL() {
  216. return _py_NIL();
  217. }
  218. late final _py_NILPtr =
  219. _lookup<ffi.NativeFunction<py_GlobalRef Function()>>('py_NIL');
  220. late final _py_NIL = _py_NILPtr.asFunction<py_GlobalRef Function()>();
  221. /// Get the current source location of the frame.
  222. ffi.Pointer<ffi.Char> py_Frame_sourceloc(
  223. ffi.Pointer<py_Frame> frame,
  224. ffi.Pointer<ffi.Int> lineno,
  225. ) {
  226. return _py_Frame_sourceloc(
  227. frame,
  228. lineno,
  229. );
  230. }
  231. late final _py_Frame_sourcelocPtr = _lookup<
  232. ffi.NativeFunction<
  233. ffi.Pointer<ffi.Char> Function(ffi.Pointer<py_Frame>,
  234. ffi.Pointer<ffi.Int>)>>('py_Frame_sourceloc');
  235. late final _py_Frame_sourceloc = _py_Frame_sourcelocPtr.asFunction<
  236. ffi.Pointer<ffi.Char> Function(
  237. ffi.Pointer<py_Frame>, ffi.Pointer<ffi.Int>)>();
  238. /// Python equivalent to `globals()` with respect to the given frame.
  239. void py_Frame_newglobals(
  240. ffi.Pointer<py_Frame> frame,
  241. py_OutRef out,
  242. ) {
  243. return _py_Frame_newglobals(
  244. frame,
  245. out,
  246. );
  247. }
  248. late final _py_Frame_newglobalsPtr = _lookup<
  249. ffi
  250. .NativeFunction<ffi.Void Function(ffi.Pointer<py_Frame>, py_OutRef)>>(
  251. 'py_Frame_newglobals');
  252. late final _py_Frame_newglobals = _py_Frame_newglobalsPtr
  253. .asFunction<void Function(ffi.Pointer<py_Frame>, py_OutRef)>();
  254. /// Python equivalent to `locals()` with respect to the given frame.
  255. void py_Frame_newlocals(
  256. ffi.Pointer<py_Frame> frame,
  257. py_OutRef out,
  258. ) {
  259. return _py_Frame_newlocals(
  260. frame,
  261. out,
  262. );
  263. }
  264. late final _py_Frame_newlocalsPtr = _lookup<
  265. ffi
  266. .NativeFunction<ffi.Void Function(ffi.Pointer<py_Frame>, py_OutRef)>>(
  267. 'py_Frame_newlocals');
  268. late final _py_Frame_newlocals = _py_Frame_newlocalsPtr
  269. .asFunction<void Function(ffi.Pointer<py_Frame>, py_OutRef)>();
  270. /// Get the function object of the frame.
  271. /// Returns `NULL` if not available.
  272. py_StackRef py_Frame_function(
  273. ffi.Pointer<py_Frame> frame,
  274. ) {
  275. return _py_Frame_function(
  276. frame,
  277. );
  278. }
  279. late final _py_Frame_functionPtr =
  280. _lookup<ffi.NativeFunction<py_StackRef Function(ffi.Pointer<py_Frame>)>>(
  281. 'py_Frame_function');
  282. late final _py_Frame_function = _py_Frame_functionPtr
  283. .asFunction<py_StackRef Function(ffi.Pointer<py_Frame>)>();
  284. /// Compile a source string into a code object.
  285. /// Use python's `exec()` or `eval()` to execute it.
  286. bool py_compile(
  287. ffi.Pointer<ffi.Char> source,
  288. ffi.Pointer<ffi.Char> filename,
  289. int mode,
  290. bool is_dynamic,
  291. ) {
  292. return _py_compile(
  293. source,
  294. filename,
  295. mode,
  296. is_dynamic,
  297. );
  298. }
  299. late final _py_compilePtr = _lookup<
  300. ffi.NativeFunction<
  301. ffi.Bool Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>,
  302. ffi.Int32, ffi.Bool)>>('py_compile');
  303. late final _py_compile = _py_compilePtr.asFunction<
  304. bool Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, int, bool)>();
  305. /// Compile a `.py` file into a `.pyc` file.
  306. bool py_compilefile(
  307. ffi.Pointer<ffi.Char> src_path,
  308. ffi.Pointer<ffi.Char> dst_path,
  309. ) {
  310. return _py_compilefile(
  311. src_path,
  312. dst_path,
  313. );
  314. }
  315. late final _py_compilefilePtr = _lookup<
  316. ffi.NativeFunction<
  317. ffi.Bool Function(
  318. ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>)>>('py_compilefile');
  319. late final _py_compilefile = _py_compilefilePtr.asFunction<
  320. bool Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>)>();
  321. /// Run a compiled code object.
  322. bool py_execo(
  323. ffi.Pointer<ffi.Void> data,
  324. int size,
  325. ffi.Pointer<ffi.Char> filename,
  326. py_Ref module,
  327. ) {
  328. return _py_execo(
  329. data,
  330. size,
  331. filename,
  332. module,
  333. );
  334. }
  335. late final _py_execoPtr = _lookup<
  336. ffi.NativeFunction<
  337. ffi.Bool Function(ffi.Pointer<ffi.Void>, ffi.Int,
  338. ffi.Pointer<ffi.Char>, py_Ref)>>('py_execo');
  339. late final _py_execo = _py_execoPtr.asFunction<
  340. bool Function(
  341. ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>, py_Ref)>();
  342. /// Run a source string.
  343. /// @param source source string.
  344. /// @param filename filename (for error messages).
  345. /// @param mode compile mode. Use `EXEC_MODE` for statements `EVAL_MODE` for expressions.
  346. /// @param module target module. Use NULL for the main module.
  347. /// @return `true` if the execution is successful or `false` if an exception is raised.
  348. bool py_exec(
  349. ffi.Pointer<ffi.Char> source,
  350. ffi.Pointer<ffi.Char> filename,
  351. int mode,
  352. py_Ref module,
  353. ) {
  354. return _py_exec(
  355. source,
  356. filename,
  357. mode,
  358. module,
  359. );
  360. }
  361. late final _py_execPtr = _lookup<
  362. ffi.NativeFunction<
  363. ffi.Bool Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>,
  364. ffi.Int32, py_Ref)>>('py_exec');
  365. late final _py_exec = _py_execPtr.asFunction<
  366. bool Function(
  367. ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, int, py_Ref)>();
  368. /// Evaluate a source string. Equivalent to `py_exec(source, "<string>", EVAL_MODE, module)`.
  369. bool py_eval(
  370. ffi.Pointer<ffi.Char> source,
  371. py_Ref module,
  372. ) {
  373. return _py_eval(
  374. source,
  375. module,
  376. );
  377. }
  378. late final _py_evalPtr = _lookup<
  379. ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Char>, py_Ref)>>(
  380. 'py_eval');
  381. late final _py_eval =
  382. _py_evalPtr.asFunction<bool Function(ffi.Pointer<ffi.Char>, py_Ref)>();
  383. /// Run a source string with smart interpretation.
  384. /// Example:
  385. /// `py_newstr(py_r0(), "abc");`
  386. /// `py_newint(py_r1(), 123);`
  387. /// `py_smartexec("print(_0, _1)", NULL, py_r0(), py_r1());`
  388. /// `// "abc 123" will be printed`.
  389. bool py_smartexec(
  390. ffi.Pointer<ffi.Char> source,
  391. py_Ref module,
  392. ) {
  393. return _py_smartexec(
  394. source,
  395. module,
  396. );
  397. }
  398. late final _py_smartexecPtr = _lookup<
  399. ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Char>, py_Ref)>>(
  400. 'py_smartexec');
  401. late final _py_smartexec = _py_smartexecPtr
  402. .asFunction<bool Function(ffi.Pointer<ffi.Char>, py_Ref)>();
  403. /// Evaluate a source string with smart interpretation.
  404. /// Example:
  405. /// `py_newstr(py_r0(), "abc");`
  406. /// `py_smarteval("len(_)", NULL, py_r0());`
  407. /// `int res = py_toint(py_retval());`
  408. /// `// res will be 3`.
  409. bool py_smarteval(
  410. ffi.Pointer<ffi.Char> source,
  411. py_Ref module,
  412. ) {
  413. return _py_smarteval(
  414. source,
  415. module,
  416. );
  417. }
  418. late final _py_smartevalPtr = _lookup<
  419. ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Char>, py_Ref)>>(
  420. 'py_smarteval');
  421. late final _py_smarteval = _py_smartevalPtr
  422. .asFunction<bool Function(ffi.Pointer<ffi.Char>, py_Ref)>();
  423. /// Create an `int` object.
  424. void py_newint(
  425. py_OutRef arg0,
  426. int arg1,
  427. ) {
  428. return _py_newint(
  429. arg0,
  430. arg1,
  431. );
  432. }
  433. late final _py_newintPtr =
  434. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, py_i64)>>(
  435. 'py_newint');
  436. late final _py_newint =
  437. _py_newintPtr.asFunction<void Function(py_OutRef, int)>();
  438. /// Create a trivial value object.
  439. void py_newtrivial(
  440. py_OutRef out,
  441. int type,
  442. ffi.Pointer<ffi.Void> data,
  443. int size,
  444. ) {
  445. return _py_newtrivial(
  446. out,
  447. type,
  448. data,
  449. size,
  450. );
  451. }
  452. late final _py_newtrivialPtr = _lookup<
  453. ffi.NativeFunction<
  454. ffi.Void Function(py_OutRef, py_Type, ffi.Pointer<ffi.Void>,
  455. ffi.Int)>>('py_newtrivial');
  456. late final _py_newtrivial = _py_newtrivialPtr
  457. .asFunction<void Function(py_OutRef, int, ffi.Pointer<ffi.Void>, int)>();
  458. /// Create a `float` object.
  459. void py_newfloat(
  460. py_OutRef arg0,
  461. double arg1,
  462. ) {
  463. return _py_newfloat(
  464. arg0,
  465. arg1,
  466. );
  467. }
  468. late final _py_newfloatPtr =
  469. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, py_f64)>>(
  470. 'py_newfloat');
  471. late final _py_newfloat =
  472. _py_newfloatPtr.asFunction<void Function(py_OutRef, double)>();
  473. /// Create a `bool` object.
  474. void py_newbool(
  475. py_OutRef arg0,
  476. bool arg1,
  477. ) {
  478. return _py_newbool(
  479. arg0,
  480. arg1,
  481. );
  482. }
  483. late final _py_newboolPtr =
  484. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, ffi.Bool)>>(
  485. 'py_newbool');
  486. late final _py_newbool =
  487. _py_newboolPtr.asFunction<void Function(py_OutRef, bool)>();
  488. /// Create a `str` object from a null-terminated string (utf-8).
  489. void py_newstr(
  490. py_OutRef arg0,
  491. ffi.Pointer<ffi.Char> arg1,
  492. ) {
  493. return _py_newstr(
  494. arg0,
  495. arg1,
  496. );
  497. }
  498. late final _py_newstrPtr = _lookup<
  499. ffi.NativeFunction<
  500. ffi.Void Function(py_OutRef, ffi.Pointer<ffi.Char>)>>('py_newstr');
  501. late final _py_newstr = _py_newstrPtr
  502. .asFunction<void Function(py_OutRef, ffi.Pointer<ffi.Char>)>();
  503. /// Create a `str` object with `n` UNINITIALIZED bytes plus `'\0'`.
  504. ffi.Pointer<ffi.Char> py_newstrn(
  505. py_OutRef arg0,
  506. int arg1,
  507. ) {
  508. return _py_newstrn(
  509. arg0,
  510. arg1,
  511. );
  512. }
  513. late final _py_newstrnPtr = _lookup<
  514. ffi.NativeFunction<
  515. ffi.Pointer<ffi.Char> Function(py_OutRef, ffi.Int)>>('py_newstrn');
  516. late final _py_newstrn = _py_newstrnPtr
  517. .asFunction<ffi.Pointer<ffi.Char> Function(py_OutRef, int)>();
  518. /// Create a `str` object from a `c11_sv`.
  519. void py_newstrv(
  520. py_OutRef arg0,
  521. c11_sv arg1,
  522. ) {
  523. return _py_newstrv(
  524. arg0,
  525. arg1,
  526. );
  527. }
  528. late final _py_newstrvPtr =
  529. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, c11_sv)>>(
  530. 'py_newstrv');
  531. late final _py_newstrv =
  532. _py_newstrvPtr.asFunction<void Function(py_OutRef, c11_sv)>();
  533. /// Create a formatted `str` object.
  534. void py_newfstr(
  535. py_OutRef arg0,
  536. ffi.Pointer<ffi.Char> arg1,
  537. ) {
  538. return _py_newfstr(
  539. arg0,
  540. arg1,
  541. );
  542. }
  543. late final _py_newfstrPtr = _lookup<
  544. ffi.NativeFunction<
  545. ffi.Void Function(py_OutRef, ffi.Pointer<ffi.Char>)>>('py_newfstr');
  546. late final _py_newfstr = _py_newfstrPtr
  547. .asFunction<void Function(py_OutRef, ffi.Pointer<ffi.Char>)>();
  548. /// Create a `bytes` object with `n` UNINITIALIZED bytes.
  549. ffi.Pointer<ffi.UnsignedChar> py_newbytes(
  550. py_OutRef arg0,
  551. int n,
  552. ) {
  553. return _py_newbytes(
  554. arg0,
  555. n,
  556. );
  557. }
  558. late final _py_newbytesPtr = _lookup<
  559. ffi.NativeFunction<
  560. ffi.Pointer<ffi.UnsignedChar> Function(
  561. py_OutRef, ffi.Int)>>('py_newbytes');
  562. late final _py_newbytes = _py_newbytesPtr
  563. .asFunction<ffi.Pointer<ffi.UnsignedChar> Function(py_OutRef, int)>();
  564. /// Create a `None` object.
  565. void py_newnone(
  566. py_OutRef arg0,
  567. ) {
  568. return _py_newnone(
  569. arg0,
  570. );
  571. }
  572. late final _py_newnonePtr =
  573. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>('py_newnone');
  574. late final _py_newnone =
  575. _py_newnonePtr.asFunction<void Function(py_OutRef)>();
  576. /// Create a `NotImplemented` object.
  577. void py_newnotimplemented(
  578. py_OutRef arg0,
  579. ) {
  580. return _py_newnotimplemented(
  581. arg0,
  582. );
  583. }
  584. late final _py_newnotimplementedPtr =
  585. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>(
  586. 'py_newnotimplemented');
  587. late final _py_newnotimplemented =
  588. _py_newnotimplementedPtr.asFunction<void Function(py_OutRef)>();
  589. /// Create a `...` object.
  590. void py_newellipsis(
  591. py_OutRef arg0,
  592. ) {
  593. return _py_newellipsis(
  594. arg0,
  595. );
  596. }
  597. late final _py_newellipsisPtr =
  598. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>(
  599. 'py_newellipsis');
  600. late final _py_newellipsis =
  601. _py_newellipsisPtr.asFunction<void Function(py_OutRef)>();
  602. /// Create a `nil` object. `nil` is an invalid representation of an object.
  603. /// Don't use it unless you know what you are doing.
  604. void py_newnil(
  605. py_OutRef arg0,
  606. ) {
  607. return _py_newnil(
  608. arg0,
  609. );
  610. }
  611. late final _py_newnilPtr =
  612. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>('py_newnil');
  613. late final _py_newnil = _py_newnilPtr.asFunction<void Function(py_OutRef)>();
  614. /// Create a `nativefunc` object.
  615. void py_newnativefunc(
  616. py_OutRef arg0,
  617. py_CFunction arg1,
  618. ) {
  619. return _py_newnativefunc(
  620. arg0,
  621. arg1,
  622. );
  623. }
  624. late final _py_newnativefuncPtr =
  625. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, py_CFunction)>>(
  626. 'py_newnativefunc');
  627. late final _py_newnativefunc =
  628. _py_newnativefuncPtr.asFunction<void Function(py_OutRef, py_CFunction)>();
  629. /// Create a `function` object.
  630. py_Name py_newfunction(
  631. py_OutRef out,
  632. ffi.Pointer<ffi.Char> sig,
  633. py_CFunction f,
  634. ffi.Pointer<ffi.Char> docstring,
  635. int slots,
  636. ) {
  637. return _py_newfunction(
  638. out,
  639. sig,
  640. f,
  641. docstring,
  642. slots,
  643. );
  644. }
  645. late final _py_newfunctionPtr = _lookup<
  646. ffi.NativeFunction<
  647. py_Name Function(py_OutRef, ffi.Pointer<ffi.Char>, py_CFunction,
  648. ffi.Pointer<ffi.Char>, ffi.Int)>>('py_newfunction');
  649. late final _py_newfunction = _py_newfunctionPtr.asFunction<
  650. py_Name Function(py_OutRef, ffi.Pointer<ffi.Char>, py_CFunction,
  651. ffi.Pointer<ffi.Char>, int)>();
  652. /// Create a `boundmethod` object.
  653. void py_newboundmethod(
  654. py_OutRef out,
  655. py_Ref self,
  656. py_Ref func,
  657. ) {
  658. return _py_newboundmethod(
  659. out,
  660. self,
  661. func,
  662. );
  663. }
  664. late final _py_newboundmethodPtr =
  665. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, py_Ref, py_Ref)>>(
  666. 'py_newboundmethod');
  667. late final _py_newboundmethod = _py_newboundmethodPtr
  668. .asFunction<void Function(py_OutRef, py_Ref, py_Ref)>();
  669. /// Create a new object.
  670. /// @param out output reference.
  671. /// @param type type of the object.
  672. /// @param slots number of slots. Use `-1` to create a `__dict__`.
  673. /// @param udsize size of your userdata.
  674. /// @return pointer to the userdata.
  675. ffi.Pointer<ffi.Void> py_newobject(
  676. py_OutRef out,
  677. int type,
  678. int slots,
  679. int udsize,
  680. ) {
  681. return _py_newobject(
  682. out,
  683. type,
  684. slots,
  685. udsize,
  686. );
  687. }
  688. late final _py_newobjectPtr = _lookup<
  689. ffi.NativeFunction<
  690. ffi.Pointer<ffi.Void> Function(
  691. py_OutRef, py_Type, ffi.Int, ffi.Int)>>('py_newobject');
  692. late final _py_newobject = _py_newobjectPtr
  693. .asFunction<ffi.Pointer<ffi.Void> Function(py_OutRef, int, int, int)>();
  694. /// Convert a null-terminated string to a name.
  695. py_Name py_name(
  696. ffi.Pointer<ffi.Char> arg0,
  697. ) {
  698. return _py_name(
  699. arg0,
  700. );
  701. }
  702. late final _py_namePtr =
  703. _lookup<ffi.NativeFunction<py_Name Function(ffi.Pointer<ffi.Char>)>>(
  704. 'py_name');
  705. late final _py_name =
  706. _py_namePtr.asFunction<py_Name Function(ffi.Pointer<ffi.Char>)>();
  707. /// Convert a name to a null-terminated string.
  708. ffi.Pointer<ffi.Char> py_name2str(
  709. py_Name arg0,
  710. ) {
  711. return _py_name2str(
  712. arg0,
  713. );
  714. }
  715. late final _py_name2strPtr =
  716. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function(py_Name)>>(
  717. 'py_name2str');
  718. late final _py_name2str =
  719. _py_name2strPtr.asFunction<ffi.Pointer<ffi.Char> Function(py_Name)>();
  720. /// Convert a name to a python `str` object with cache.
  721. py_GlobalRef py_name2ref(
  722. py_Name arg0,
  723. ) {
  724. return _py_name2ref(
  725. arg0,
  726. );
  727. }
  728. late final _py_name2refPtr =
  729. _lookup<ffi.NativeFunction<py_GlobalRef Function(py_Name)>>(
  730. 'py_name2ref');
  731. late final _py_name2ref =
  732. _py_name2refPtr.asFunction<py_GlobalRef Function(py_Name)>();
  733. /// Convert a `c11_sv` to a name.
  734. py_Name py_namev(
  735. c11_sv arg0,
  736. ) {
  737. return _py_namev(
  738. arg0,
  739. );
  740. }
  741. late final _py_namevPtr =
  742. _lookup<ffi.NativeFunction<py_Name Function(c11_sv)>>('py_namev');
  743. late final _py_namev = _py_namevPtr.asFunction<py_Name Function(c11_sv)>();
  744. /// Convert a name to a `c11_sv`.
  745. c11_sv py_name2sv(
  746. py_Name arg0,
  747. ) {
  748. return _py_name2sv(
  749. arg0,
  750. );
  751. }
  752. late final _py_name2svPtr =
  753. _lookup<ffi.NativeFunction<c11_sv Function(py_Name)>>('py_name2sv');
  754. late final _py_name2sv =
  755. _py_name2svPtr.asFunction<c11_sv Function(py_Name)>();
  756. /// Bind a function to the object via "decl-based" style.
  757. /// @param obj the target object.
  758. /// @param sig signature of the function. e.g. `add(x, y)`.
  759. /// @param f function to bind.
  760. void py_bind(
  761. py_Ref obj,
  762. ffi.Pointer<ffi.Char> sig,
  763. py_CFunction f,
  764. ) {
  765. return _py_bind(
  766. obj,
  767. sig,
  768. f,
  769. );
  770. }
  771. late final _py_bindPtr = _lookup<
  772. ffi.NativeFunction<
  773. ffi.Void Function(
  774. py_Ref, ffi.Pointer<ffi.Char>, py_CFunction)>>('py_bind');
  775. late final _py_bind = _py_bindPtr
  776. .asFunction<void Function(py_Ref, ffi.Pointer<ffi.Char>, py_CFunction)>();
  777. /// Bind a method to type via "argc-based" style.
  778. /// @param type the target type.
  779. /// @param name name of the method.
  780. /// @param f function to bind.
  781. void py_bindmethod(
  782. int type,
  783. ffi.Pointer<ffi.Char> name,
  784. py_CFunction f,
  785. ) {
  786. return _py_bindmethod(
  787. type,
  788. name,
  789. f,
  790. );
  791. }
  792. late final _py_bindmethodPtr = _lookup<
  793. ffi.NativeFunction<
  794. ffi.Void Function(
  795. py_Type, ffi.Pointer<ffi.Char>, py_CFunction)>>('py_bindmethod');
  796. late final _py_bindmethod = _py_bindmethodPtr
  797. .asFunction<void Function(int, ffi.Pointer<ffi.Char>, py_CFunction)>();
  798. /// Bind a static method to type via "argc-based" style.
  799. /// @param type the target type.
  800. /// @param name name of the method.
  801. /// @param f function to bind.
  802. void py_bindstaticmethod(
  803. int type,
  804. ffi.Pointer<ffi.Char> name,
  805. py_CFunction f,
  806. ) {
  807. return _py_bindstaticmethod(
  808. type,
  809. name,
  810. f,
  811. );
  812. }
  813. late final _py_bindstaticmethodPtr = _lookup<
  814. ffi.NativeFunction<
  815. ffi.Void Function(py_Type, ffi.Pointer<ffi.Char>,
  816. py_CFunction)>>('py_bindstaticmethod');
  817. late final _py_bindstaticmethod = _py_bindstaticmethodPtr
  818. .asFunction<void Function(int, ffi.Pointer<ffi.Char>, py_CFunction)>();
  819. /// Bind a function to the object via "argc-based" style.
  820. /// @param obj the target object.
  821. /// @param name name of the function.
  822. /// @param f function to bind.
  823. void py_bindfunc(
  824. py_Ref obj,
  825. ffi.Pointer<ffi.Char> name,
  826. py_CFunction f,
  827. ) {
  828. return _py_bindfunc(
  829. obj,
  830. name,
  831. f,
  832. );
  833. }
  834. late final _py_bindfuncPtr = _lookup<
  835. ffi.NativeFunction<
  836. ffi.Void Function(
  837. py_Ref, ffi.Pointer<ffi.Char>, py_CFunction)>>('py_bindfunc');
  838. late final _py_bindfunc = _py_bindfuncPtr
  839. .asFunction<void Function(py_Ref, ffi.Pointer<ffi.Char>, py_CFunction)>();
  840. /// Bind a property to type.
  841. /// @param type the target type.
  842. /// @param name name of the property.
  843. /// @param getter getter function.
  844. /// @param setter setter function. Use `NULL` if not needed.
  845. void py_bindproperty(
  846. int type,
  847. ffi.Pointer<ffi.Char> name,
  848. py_CFunction getter,
  849. py_CFunction setter,
  850. ) {
  851. return _py_bindproperty(
  852. type,
  853. name,
  854. getter,
  855. setter,
  856. );
  857. }
  858. late final _py_bindpropertyPtr = _lookup<
  859. ffi.NativeFunction<
  860. ffi.Void Function(py_Type, ffi.Pointer<ffi.Char>, py_CFunction,
  861. py_CFunction)>>('py_bindproperty');
  862. late final _py_bindproperty = _py_bindpropertyPtr.asFunction<
  863. void Function(int, ffi.Pointer<ffi.Char>, py_CFunction, py_CFunction)>();
  864. /// Bind a magic method to type.
  865. void py_bindmagic(
  866. int type,
  867. py_Name name,
  868. py_CFunction f,
  869. ) {
  870. return _py_bindmagic(
  871. type,
  872. name,
  873. f,
  874. );
  875. }
  876. late final _py_bindmagicPtr = _lookup<
  877. ffi.NativeFunction<
  878. ffi.Void Function(py_Type, py_Name, py_CFunction)>>('py_bindmagic');
  879. late final _py_bindmagic =
  880. _py_bindmagicPtr.asFunction<void Function(int, py_Name, py_CFunction)>();
  881. /// Convert an `int` object in python to `int64_t`.
  882. int py_toint(
  883. py_Ref arg0,
  884. ) {
  885. return _py_toint(
  886. arg0,
  887. );
  888. }
  889. late final _py_tointPtr =
  890. _lookup<ffi.NativeFunction<py_i64 Function(py_Ref)>>('py_toint');
  891. late final _py_toint = _py_tointPtr.asFunction<int Function(py_Ref)>();
  892. /// Get the address of the trivial value object (16 bytes).
  893. ffi.Pointer<ffi.Void> py_totrivial(
  894. py_Ref arg0,
  895. ) {
  896. return _py_totrivial(
  897. arg0,
  898. );
  899. }
  900. late final _py_totrivialPtr =
  901. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Void> Function(py_Ref)>>(
  902. 'py_totrivial');
  903. late final _py_totrivial =
  904. _py_totrivialPtr.asFunction<ffi.Pointer<ffi.Void> Function(py_Ref)>();
  905. /// Convert a `float` object in python to `double`.
  906. double py_tofloat(
  907. py_Ref arg0,
  908. ) {
  909. return _py_tofloat(
  910. arg0,
  911. );
  912. }
  913. late final _py_tofloatPtr =
  914. _lookup<ffi.NativeFunction<py_f64 Function(py_Ref)>>('py_tofloat');
  915. late final _py_tofloat = _py_tofloatPtr.asFunction<double Function(py_Ref)>();
  916. /// Cast a `int` or `float` object in python to `double`.
  917. /// If successful, return true and set the value to `out`.
  918. /// Otherwise, return false and raise `TypeError`.
  919. bool py_castfloat(
  920. py_Ref arg0,
  921. ffi.Pointer<py_f64> out,
  922. ) {
  923. return _py_castfloat(
  924. arg0,
  925. out,
  926. );
  927. }
  928. late final _py_castfloatPtr = _lookup<
  929. ffi.NativeFunction<ffi.Bool Function(py_Ref, ffi.Pointer<py_f64>)>>(
  930. 'py_castfloat');
  931. late final _py_castfloat =
  932. _py_castfloatPtr.asFunction<bool Function(py_Ref, ffi.Pointer<py_f64>)>();
  933. /// 32-bit version of `py_castfloat`.
  934. bool py_castfloat32(
  935. py_Ref arg0,
  936. ffi.Pointer<ffi.Float> out,
  937. ) {
  938. return _py_castfloat32(
  939. arg0,
  940. out,
  941. );
  942. }
  943. late final _py_castfloat32Ptr = _lookup<
  944. ffi.NativeFunction<
  945. ffi.Bool Function(py_Ref, ffi.Pointer<ffi.Float>)>>('py_castfloat32');
  946. late final _py_castfloat32 = _py_castfloat32Ptr
  947. .asFunction<bool Function(py_Ref, ffi.Pointer<ffi.Float>)>();
  948. /// Cast a `int` object in python to `int64_t`.
  949. bool py_castint(
  950. py_Ref arg0,
  951. ffi.Pointer<py_i64> out,
  952. ) {
  953. return _py_castint(
  954. arg0,
  955. out,
  956. );
  957. }
  958. late final _py_castintPtr = _lookup<
  959. ffi.NativeFunction<ffi.Bool Function(py_Ref, ffi.Pointer<py_i64>)>>(
  960. 'py_castint');
  961. late final _py_castint =
  962. _py_castintPtr.asFunction<bool Function(py_Ref, ffi.Pointer<py_i64>)>();
  963. /// Convert a `bool` object in python to `bool`.
  964. bool py_tobool(
  965. py_Ref arg0,
  966. ) {
  967. return _py_tobool(
  968. arg0,
  969. );
  970. }
  971. late final _py_toboolPtr =
  972. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_tobool');
  973. late final _py_tobool = _py_toboolPtr.asFunction<bool Function(py_Ref)>();
  974. /// Convert a `type` object in python to `py_Type`.
  975. int py_totype(
  976. py_Ref arg0,
  977. ) {
  978. return _py_totype(
  979. arg0,
  980. );
  981. }
  982. late final _py_totypePtr =
  983. _lookup<ffi.NativeFunction<py_Type Function(py_Ref)>>('py_totype');
  984. late final _py_totype = _py_totypePtr.asFunction<int Function(py_Ref)>();
  985. /// Convert a user-defined object to its userdata.
  986. ffi.Pointer<ffi.Void> py_touserdata(
  987. py_Ref arg0,
  988. ) {
  989. return _py_touserdata(
  990. arg0,
  991. );
  992. }
  993. late final _py_touserdataPtr =
  994. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Void> Function(py_Ref)>>(
  995. 'py_touserdata');
  996. late final _py_touserdata =
  997. _py_touserdataPtr.asFunction<ffi.Pointer<ffi.Void> Function(py_Ref)>();
  998. /// Convert a `str` object in python to null-terminated string.
  999. ffi.Pointer<ffi.Char> py_tostr(
  1000. py_Ref arg0,
  1001. ) {
  1002. return _py_tostr(
  1003. arg0,
  1004. );
  1005. }
  1006. late final _py_tostrPtr =
  1007. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function(py_Ref)>>(
  1008. 'py_tostr');
  1009. late final _py_tostr =
  1010. _py_tostrPtr.asFunction<ffi.Pointer<ffi.Char> Function(py_Ref)>();
  1011. /// Convert a `str` object in python to char array.
  1012. ffi.Pointer<ffi.Char> py_tostrn(
  1013. py_Ref arg0,
  1014. ffi.Pointer<ffi.Int> size,
  1015. ) {
  1016. return _py_tostrn(
  1017. arg0,
  1018. size,
  1019. );
  1020. }
  1021. late final _py_tostrnPtr = _lookup<
  1022. ffi.NativeFunction<
  1023. ffi.Pointer<ffi.Char> Function(
  1024. py_Ref, ffi.Pointer<ffi.Int>)>>('py_tostrn');
  1025. late final _py_tostrn = _py_tostrnPtr.asFunction<
  1026. ffi.Pointer<ffi.Char> Function(py_Ref, ffi.Pointer<ffi.Int>)>();
  1027. /// Convert a `str` object in python to `c11_sv`.
  1028. c11_sv py_tosv(
  1029. py_Ref arg0,
  1030. ) {
  1031. return _py_tosv(
  1032. arg0,
  1033. );
  1034. }
  1035. late final _py_tosvPtr =
  1036. _lookup<ffi.NativeFunction<c11_sv Function(py_Ref)>>('py_tosv');
  1037. late final _py_tosv = _py_tosvPtr.asFunction<c11_sv Function(py_Ref)>();
  1038. /// Convert a `bytes` object in python to char array.
  1039. ffi.Pointer<ffi.UnsignedChar> py_tobytes(
  1040. py_Ref arg0,
  1041. ffi.Pointer<ffi.Int> size,
  1042. ) {
  1043. return _py_tobytes(
  1044. arg0,
  1045. size,
  1046. );
  1047. }
  1048. late final _py_tobytesPtr = _lookup<
  1049. ffi.NativeFunction<
  1050. ffi.Pointer<ffi.UnsignedChar> Function(
  1051. py_Ref, ffi.Pointer<ffi.Int>)>>('py_tobytes');
  1052. late final _py_tobytes = _py_tobytesPtr.asFunction<
  1053. ffi.Pointer<ffi.UnsignedChar> Function(py_Ref, ffi.Pointer<ffi.Int>)>();
  1054. /// Resize a `bytes` object. It can only be resized down.
  1055. void py_bytes_resize(
  1056. py_Ref arg0,
  1057. int size,
  1058. ) {
  1059. return _py_bytes_resize(
  1060. arg0,
  1061. size,
  1062. );
  1063. }
  1064. late final _py_bytes_resizePtr =
  1065. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int)>>(
  1066. 'py_bytes_resize');
  1067. late final _py_bytes_resize =
  1068. _py_bytes_resizePtr.asFunction<void Function(py_Ref, int)>();
  1069. /// Create a new type.
  1070. /// @param name name of the type.
  1071. /// @param base base type.
  1072. /// @param module module where the type is defined. Use `NULL` for built-in types.
  1073. /// @param dtor destructor function. Use `NULL` if not needed.
  1074. int py_newtype(
  1075. ffi.Pointer<ffi.Char> name,
  1076. int base,
  1077. py_GlobalRef module,
  1078. py_Dtor dtor,
  1079. ) {
  1080. return _py_newtype(
  1081. name,
  1082. base,
  1083. module,
  1084. dtor,
  1085. );
  1086. }
  1087. late final _py_newtypePtr = _lookup<
  1088. ffi.NativeFunction<
  1089. py_Type Function(ffi.Pointer<ffi.Char>, py_Type, py_GlobalRef,
  1090. py_Dtor)>>('py_newtype');
  1091. late final _py_newtype = _py_newtypePtr.asFunction<
  1092. int Function(ffi.Pointer<ffi.Char>, int, py_GlobalRef, py_Dtor)>();
  1093. /// Check if the object is exactly the given type.
  1094. bool py_istype(
  1095. py_Ref arg0,
  1096. int arg1,
  1097. ) {
  1098. return _py_istype(
  1099. arg0,
  1100. arg1,
  1101. );
  1102. }
  1103. late final _py_istypePtr =
  1104. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Type)>>(
  1105. 'py_istype');
  1106. late final _py_istype =
  1107. _py_istypePtr.asFunction<bool Function(py_Ref, int)>();
  1108. /// Get the type of the object.
  1109. int py_typeof(
  1110. py_Ref self,
  1111. ) {
  1112. return _py_typeof(
  1113. self,
  1114. );
  1115. }
  1116. late final _py_typeofPtr =
  1117. _lookup<ffi.NativeFunction<py_Type Function(py_Ref)>>('py_typeof');
  1118. late final _py_typeof = _py_typeofPtr.asFunction<int Function(py_Ref)>();
  1119. /// Check if the object is an instance of the given type.
  1120. bool py_isinstance(
  1121. py_Ref obj,
  1122. int type,
  1123. ) {
  1124. return _py_isinstance(
  1125. obj,
  1126. type,
  1127. );
  1128. }
  1129. late final _py_isinstancePtr =
  1130. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Type)>>(
  1131. 'py_isinstance');
  1132. late final _py_isinstance =
  1133. _py_isinstancePtr.asFunction<bool Function(py_Ref, int)>();
  1134. /// Check if the derived type is a subclass of the base type.
  1135. bool py_issubclass(
  1136. int derived,
  1137. int base,
  1138. ) {
  1139. return _py_issubclass(
  1140. derived,
  1141. base,
  1142. );
  1143. }
  1144. late final _py_issubclassPtr =
  1145. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Type, py_Type)>>(
  1146. 'py_issubclass');
  1147. late final _py_issubclass =
  1148. _py_issubclassPtr.asFunction<bool Function(int, int)>();
  1149. /// Get type by module and name. e.g. `py_gettype("time", py_name("struct_time"))`.
  1150. /// Return `0` if not found.
  1151. int py_gettype(
  1152. ffi.Pointer<ffi.Char> module,
  1153. py_Name name,
  1154. ) {
  1155. return _py_gettype(
  1156. module,
  1157. name,
  1158. );
  1159. }
  1160. late final _py_gettypePtr = _lookup<
  1161. ffi.NativeFunction<py_Type Function(ffi.Pointer<ffi.Char>, py_Name)>>(
  1162. 'py_gettype');
  1163. late final _py_gettype =
  1164. _py_gettypePtr.asFunction<int Function(ffi.Pointer<ffi.Char>, py_Name)>();
  1165. /// Check if the object is an instance of the given type exactly.
  1166. /// Raise `TypeError` if the check fails.
  1167. bool py_checktype(
  1168. py_Ref self,
  1169. int type,
  1170. ) {
  1171. return _py_checktype(
  1172. self,
  1173. type,
  1174. );
  1175. }
  1176. late final _py_checktypePtr =
  1177. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Type)>>(
  1178. 'py_checktype');
  1179. late final _py_checktype =
  1180. _py_checktypePtr.asFunction<bool Function(py_Ref, int)>();
  1181. /// Check if the object is an instance of the given type or its subclass.
  1182. /// Raise `TypeError` if the check fails.
  1183. bool py_checkinstance(
  1184. py_Ref self,
  1185. int type,
  1186. ) {
  1187. return _py_checkinstance(
  1188. self,
  1189. type,
  1190. );
  1191. }
  1192. late final _py_checkinstancePtr =
  1193. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Type)>>(
  1194. 'py_checkinstance');
  1195. late final _py_checkinstance =
  1196. _py_checkinstancePtr.asFunction<bool Function(py_Ref, int)>();
  1197. /// Get the magic method from the given type only.
  1198. /// Return `nil` if not found.
  1199. py_GlobalRef py_tpgetmagic(
  1200. int type,
  1201. py_Name name,
  1202. ) {
  1203. return _py_tpgetmagic(
  1204. type,
  1205. name,
  1206. );
  1207. }
  1208. late final _py_tpgetmagicPtr =
  1209. _lookup<ffi.NativeFunction<py_GlobalRef Function(py_Type, py_Name)>>(
  1210. 'py_tpgetmagic');
  1211. late final _py_tpgetmagic =
  1212. _py_tpgetmagicPtr.asFunction<py_GlobalRef Function(int, py_Name)>();
  1213. /// Search the magic method from the given type to the base type.
  1214. /// Return `NULL` if not found.
  1215. py_GlobalRef py_tpfindmagic(
  1216. int arg0,
  1217. py_Name name,
  1218. ) {
  1219. return _py_tpfindmagic(
  1220. arg0,
  1221. name,
  1222. );
  1223. }
  1224. late final _py_tpfindmagicPtr =
  1225. _lookup<ffi.NativeFunction<py_GlobalRef Function(py_Type, py_Name)>>(
  1226. 'py_tpfindmagic');
  1227. late final _py_tpfindmagic =
  1228. _py_tpfindmagicPtr.asFunction<py_GlobalRef Function(int, py_Name)>();
  1229. /// Search the name from the given type to the base type.
  1230. /// Return `NULL` if not found.
  1231. py_ItemRef py_tpfindname(
  1232. int arg0,
  1233. py_Name name,
  1234. ) {
  1235. return _py_tpfindname(
  1236. arg0,
  1237. name,
  1238. );
  1239. }
  1240. late final _py_tpfindnamePtr =
  1241. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Type, py_Name)>>(
  1242. 'py_tpfindname');
  1243. late final _py_tpfindname =
  1244. _py_tpfindnamePtr.asFunction<py_ItemRef Function(int, py_Name)>();
  1245. /// Get the base type of the given type.
  1246. int py_tpbase(
  1247. int type,
  1248. ) {
  1249. return _py_tpbase(
  1250. type,
  1251. );
  1252. }
  1253. late final _py_tpbasePtr =
  1254. _lookup<ffi.NativeFunction<py_Type Function(py_Type)>>('py_tpbase');
  1255. late final _py_tpbase = _py_tpbasePtr.asFunction<int Function(int)>();
  1256. /// Get the type object of the given type.
  1257. py_GlobalRef py_tpobject(
  1258. int type,
  1259. ) {
  1260. return _py_tpobject(
  1261. type,
  1262. );
  1263. }
  1264. late final _py_tpobjectPtr =
  1265. _lookup<ffi.NativeFunction<py_GlobalRef Function(py_Type)>>(
  1266. 'py_tpobject');
  1267. late final _py_tpobject =
  1268. _py_tpobjectPtr.asFunction<py_GlobalRef Function(int)>();
  1269. /// Get the type name.
  1270. ffi.Pointer<ffi.Char> py_tpname(
  1271. int type,
  1272. ) {
  1273. return _py_tpname(
  1274. type,
  1275. );
  1276. }
  1277. late final _py_tpnamePtr =
  1278. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function(py_Type)>>(
  1279. 'py_tpname');
  1280. late final _py_tpname =
  1281. _py_tpnamePtr.asFunction<ffi.Pointer<ffi.Char> Function(int)>();
  1282. /// Disable the type for subclassing.
  1283. void py_tpsetfinal(
  1284. int type,
  1285. ) {
  1286. return _py_tpsetfinal(
  1287. type,
  1288. );
  1289. }
  1290. late final _py_tpsetfinalPtr =
  1291. _lookup<ffi.NativeFunction<ffi.Void Function(py_Type)>>('py_tpsetfinal');
  1292. late final _py_tpsetfinal =
  1293. _py_tpsetfinalPtr.asFunction<void Function(int)>();
  1294. /// Set attribute hooks for the given type.
  1295. void py_tphookattributes(
  1296. int type,
  1297. ffi.Pointer<
  1298. ffi.NativeFunction<ffi.Bool Function(py_Ref self, py_Name name)>>
  1299. getattribute,
  1300. ffi.Pointer<
  1301. ffi.NativeFunction<
  1302. ffi.Bool Function(py_Ref self, py_Name name, py_Ref val)>>
  1303. setattribute,
  1304. ffi.Pointer<
  1305. ffi.NativeFunction<ffi.Bool Function(py_Ref self, py_Name name)>>
  1306. delattribute,
  1307. ffi.Pointer<
  1308. ffi.NativeFunction<ffi.Bool Function(py_Ref self, py_Name name)>>
  1309. getunboundmethod,
  1310. ) {
  1311. return _py_tphookattributes(
  1312. type,
  1313. getattribute,
  1314. setattribute,
  1315. delattribute,
  1316. getunboundmethod,
  1317. );
  1318. }
  1319. late final _py_tphookattributesPtr = _lookup<
  1320. ffi.NativeFunction<
  1321. ffi.Void Function(
  1322. py_Type,
  1323. ffi.Pointer<
  1324. ffi.NativeFunction<
  1325. ffi.Bool Function(py_Ref self, py_Name name)>>,
  1326. ffi.Pointer<
  1327. ffi.NativeFunction<
  1328. ffi.Bool Function(
  1329. py_Ref self, py_Name name, py_Ref val)>>,
  1330. ffi.Pointer<
  1331. ffi.NativeFunction<
  1332. ffi.Bool Function(py_Ref self, py_Name name)>>,
  1333. ffi.Pointer<
  1334. ffi.NativeFunction<
  1335. ffi.Bool Function(py_Ref self,
  1336. py_Name name)>>)>>('py_tphookattributes');
  1337. late final _py_tphookattributes = _py_tphookattributesPtr.asFunction<
  1338. void Function(
  1339. int,
  1340. ffi.Pointer<
  1341. ffi.NativeFunction<ffi.Bool Function(py_Ref self, py_Name name)>>,
  1342. ffi.Pointer<
  1343. ffi.NativeFunction<
  1344. ffi.Bool Function(py_Ref self, py_Name name, py_Ref val)>>,
  1345. ffi.Pointer<
  1346. ffi.NativeFunction<ffi.Bool Function(py_Ref self, py_Name name)>>,
  1347. ffi.Pointer<
  1348. ffi.NativeFunction<
  1349. ffi.Bool Function(py_Ref self, py_Name name)>>)>();
  1350. /// Get the current `Callable` object on the stack of the most recent vectorcall.
  1351. /// Return `NULL` if not available.
  1352. /// NOTE: This function should be placed at the beginning of your bindings or you will get wrong result.
  1353. py_StackRef py_inspect_currentfunction() {
  1354. return _py_inspect_currentfunction();
  1355. }
  1356. late final _py_inspect_currentfunctionPtr =
  1357. _lookup<ffi.NativeFunction<py_StackRef Function()>>(
  1358. 'py_inspect_currentfunction');
  1359. late final _py_inspect_currentfunction =
  1360. _py_inspect_currentfunctionPtr.asFunction<py_StackRef Function()>();
  1361. /// Get the current `module` object where the code is executed.
  1362. /// Return `NULL` if not available.
  1363. py_GlobalRef py_inspect_currentmodule() {
  1364. return _py_inspect_currentmodule();
  1365. }
  1366. late final _py_inspect_currentmodulePtr =
  1367. _lookup<ffi.NativeFunction<py_GlobalRef Function()>>(
  1368. 'py_inspect_currentmodule');
  1369. late final _py_inspect_currentmodule =
  1370. _py_inspect_currentmodulePtr.asFunction<py_GlobalRef Function()>();
  1371. /// Get the current frame object.
  1372. /// Return `NULL` if not available.
  1373. ffi.Pointer<py_Frame> py_inspect_currentframe() {
  1374. return _py_inspect_currentframe();
  1375. }
  1376. late final _py_inspect_currentframePtr =
  1377. _lookup<ffi.NativeFunction<ffi.Pointer<py_Frame> Function()>>(
  1378. 'py_inspect_currentframe');
  1379. late final _py_inspect_currentframe = _py_inspect_currentframePtr
  1380. .asFunction<ffi.Pointer<py_Frame> Function()>();
  1381. /// Python equivalent to `globals()`.
  1382. void py_newglobals(
  1383. py_OutRef arg0,
  1384. ) {
  1385. return _py_newglobals(
  1386. arg0,
  1387. );
  1388. }
  1389. late final _py_newglobalsPtr =
  1390. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>(
  1391. 'py_newglobals');
  1392. late final _py_newglobals =
  1393. _py_newglobalsPtr.asFunction<void Function(py_OutRef)>();
  1394. /// Python equivalent to `locals()`.
  1395. void py_newlocals(
  1396. py_OutRef arg0,
  1397. ) {
  1398. return _py_newlocals(
  1399. arg0,
  1400. );
  1401. }
  1402. late final _py_newlocalsPtr =
  1403. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>('py_newlocals');
  1404. late final _py_newlocals =
  1405. _py_newlocalsPtr.asFunction<void Function(py_OutRef)>();
  1406. /// Get the i-th register.
  1407. /// All registers are located in a contiguous memory.
  1408. py_GlobalRef py_getreg(
  1409. int i,
  1410. ) {
  1411. return _py_getreg(
  1412. i,
  1413. );
  1414. }
  1415. late final _py_getregPtr =
  1416. _lookup<ffi.NativeFunction<py_GlobalRef Function(ffi.Int)>>('py_getreg');
  1417. late final _py_getreg =
  1418. _py_getregPtr.asFunction<py_GlobalRef Function(int)>();
  1419. /// Set the i-th register.
  1420. void py_setreg(
  1421. int i,
  1422. py_Ref val,
  1423. ) {
  1424. return _py_setreg(
  1425. i,
  1426. val,
  1427. );
  1428. }
  1429. late final _py_setregPtr =
  1430. _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int, py_Ref)>>(
  1431. 'py_setreg');
  1432. late final _py_setreg =
  1433. _py_setregPtr.asFunction<void Function(int, py_Ref)>();
  1434. /// Get the last return value.
  1435. /// Please note that `py_retval()` cannot be used as input argument.
  1436. py_GlobalRef py_retval() {
  1437. return _py_retval();
  1438. }
  1439. late final _py_retvalPtr =
  1440. _lookup<ffi.NativeFunction<py_GlobalRef Function()>>('py_retval');
  1441. late final _py_retval = _py_retvalPtr.asFunction<py_GlobalRef Function()>();
  1442. /// Get an item from the object's `__dict__`.
  1443. /// Return `NULL` if not found.
  1444. py_ItemRef py_getdict(
  1445. py_Ref self,
  1446. py_Name name,
  1447. ) {
  1448. return _py_getdict(
  1449. self,
  1450. name,
  1451. );
  1452. }
  1453. late final _py_getdictPtr =
  1454. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Ref, py_Name)>>(
  1455. 'py_getdict');
  1456. late final _py_getdict =
  1457. _py_getdictPtr.asFunction<py_ItemRef Function(py_Ref, py_Name)>();
  1458. /// Set an item to the object's `__dict__`.
  1459. void py_setdict(
  1460. py_Ref self,
  1461. py_Name name,
  1462. py_Ref val,
  1463. ) {
  1464. return _py_setdict(
  1465. self,
  1466. name,
  1467. val,
  1468. );
  1469. }
  1470. late final _py_setdictPtr =
  1471. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, py_Name, py_Ref)>>(
  1472. 'py_setdict');
  1473. late final _py_setdict =
  1474. _py_setdictPtr.asFunction<void Function(py_Ref, py_Name, py_Ref)>();
  1475. /// Delete an item from the object's `__dict__`.
  1476. /// Return `true` if the deletion is successful.
  1477. bool py_deldict(
  1478. py_Ref self,
  1479. py_Name name,
  1480. ) {
  1481. return _py_deldict(
  1482. self,
  1483. name,
  1484. );
  1485. }
  1486. late final _py_deldictPtr =
  1487. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Name)>>(
  1488. 'py_deldict');
  1489. late final _py_deldict =
  1490. _py_deldictPtr.asFunction<bool Function(py_Ref, py_Name)>();
  1491. /// Prepare an insertion to the object's `__dict__`.
  1492. py_ItemRef py_emplacedict(
  1493. py_Ref self,
  1494. py_Name name,
  1495. ) {
  1496. return _py_emplacedict(
  1497. self,
  1498. name,
  1499. );
  1500. }
  1501. late final _py_emplacedictPtr =
  1502. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Ref, py_Name)>>(
  1503. 'py_emplacedict');
  1504. late final _py_emplacedict =
  1505. _py_emplacedictPtr.asFunction<py_ItemRef Function(py_Ref, py_Name)>();
  1506. /// Apply a function to all items in the object's `__dict__`.
  1507. /// Return `true` if the function is successful for all items.
  1508. /// NOTE: Be careful if `f` modifies the object's `__dict__`.
  1509. bool py_applydict(
  1510. py_Ref self,
  1511. ffi.Pointer<
  1512. ffi.NativeFunction<
  1513. ffi.Bool Function(
  1514. py_Name name, py_Ref val, ffi.Pointer<ffi.Void> ctx)>>
  1515. f,
  1516. ffi.Pointer<ffi.Void> ctx,
  1517. ) {
  1518. return _py_applydict(
  1519. self,
  1520. f,
  1521. ctx,
  1522. );
  1523. }
  1524. late final _py_applydictPtr = _lookup<
  1525. ffi.NativeFunction<
  1526. ffi.Bool Function(
  1527. py_Ref,
  1528. ffi.Pointer<
  1529. ffi.NativeFunction<
  1530. ffi.Bool Function(py_Name name, py_Ref val,
  1531. ffi.Pointer<ffi.Void> ctx)>>,
  1532. ffi.Pointer<ffi.Void>)>>('py_applydict');
  1533. late final _py_applydict = _py_applydictPtr.asFunction<
  1534. bool Function(
  1535. py_Ref,
  1536. ffi.Pointer<
  1537. ffi.NativeFunction<
  1538. ffi.Bool Function(
  1539. py_Name name, py_Ref val, ffi.Pointer<ffi.Void> ctx)>>,
  1540. ffi.Pointer<ffi.Void>)>();
  1541. /// Clear the object's `__dict__`. This function is dangerous.
  1542. void py_cleardict(
  1543. py_Ref self,
  1544. ) {
  1545. return _py_cleardict(
  1546. self,
  1547. );
  1548. }
  1549. late final _py_cleardictPtr =
  1550. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref)>>('py_cleardict');
  1551. late final _py_cleardict =
  1552. _py_cleardictPtr.asFunction<void Function(py_Ref)>();
  1553. /// Get the i-th slot of the object.
  1554. /// The object must have slots and `i` must be in valid range.
  1555. py_ObjectRef py_getslot(
  1556. py_Ref self,
  1557. int i,
  1558. ) {
  1559. return _py_getslot(
  1560. self,
  1561. i,
  1562. );
  1563. }
  1564. late final _py_getslotPtr =
  1565. _lookup<ffi.NativeFunction<py_ObjectRef Function(py_Ref, ffi.Int)>>(
  1566. 'py_getslot');
  1567. late final _py_getslot =
  1568. _py_getslotPtr.asFunction<py_ObjectRef Function(py_Ref, int)>();
  1569. /// Set the i-th slot of the object.
  1570. void py_setslot(
  1571. py_Ref self,
  1572. int i,
  1573. py_Ref val,
  1574. ) {
  1575. return _py_setslot(
  1576. self,
  1577. i,
  1578. val,
  1579. );
  1580. }
  1581. late final _py_setslotPtr =
  1582. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int, py_Ref)>>(
  1583. 'py_setslot');
  1584. late final _py_setslot =
  1585. _py_setslotPtr.asFunction<void Function(py_Ref, int, py_Ref)>();
  1586. /// Get variable in the `builtins` module.
  1587. py_ItemRef py_getbuiltin(
  1588. py_Name name,
  1589. ) {
  1590. return _py_getbuiltin(
  1591. name,
  1592. );
  1593. }
  1594. late final _py_getbuiltinPtr =
  1595. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Name)>>(
  1596. 'py_getbuiltin');
  1597. late final _py_getbuiltin =
  1598. _py_getbuiltinPtr.asFunction<py_ItemRef Function(py_Name)>();
  1599. /// Get variable in the `__main__` module.
  1600. py_ItemRef py_getglobal(
  1601. py_Name name,
  1602. ) {
  1603. return _py_getglobal(
  1604. name,
  1605. );
  1606. }
  1607. late final _py_getglobalPtr =
  1608. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Name)>>('py_getglobal');
  1609. late final _py_getglobal =
  1610. _py_getglobalPtr.asFunction<py_ItemRef Function(py_Name)>();
  1611. /// Set variable in the `__main__` module.
  1612. void py_setglobal(
  1613. py_Name name,
  1614. py_Ref val,
  1615. ) {
  1616. return _py_setglobal(
  1617. name,
  1618. val,
  1619. );
  1620. }
  1621. late final _py_setglobalPtr =
  1622. _lookup<ffi.NativeFunction<ffi.Void Function(py_Name, py_Ref)>>(
  1623. 'py_setglobal');
  1624. late final _py_setglobal =
  1625. _py_setglobalPtr.asFunction<void Function(py_Name, py_Ref)>();
  1626. /// Get the i-th object from the top of the stack.
  1627. /// `i` should be negative, e.g. (-1) means TOS.
  1628. py_StackRef py_peek(
  1629. int i,
  1630. ) {
  1631. return _py_peek(
  1632. i,
  1633. );
  1634. }
  1635. late final _py_peekPtr =
  1636. _lookup<ffi.NativeFunction<py_StackRef Function(ffi.Int)>>('py_peek');
  1637. late final _py_peek = _py_peekPtr.asFunction<py_StackRef Function(int)>();
  1638. /// Push the object to the stack.
  1639. void py_push(
  1640. py_Ref src,
  1641. ) {
  1642. return _py_push(
  1643. src,
  1644. );
  1645. }
  1646. late final _py_pushPtr =
  1647. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref)>>('py_push');
  1648. late final _py_push = _py_pushPtr.asFunction<void Function(py_Ref)>();
  1649. /// Push a `nil` object to the stack.
  1650. void py_pushnil() {
  1651. return _py_pushnil();
  1652. }
  1653. late final _py_pushnilPtr =
  1654. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_pushnil');
  1655. late final _py_pushnil = _py_pushnilPtr.asFunction<void Function()>();
  1656. /// Push a `None` object to the stack.
  1657. void py_pushnone() {
  1658. return _py_pushnone();
  1659. }
  1660. late final _py_pushnonePtr =
  1661. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_pushnone');
  1662. late final _py_pushnone = _py_pushnonePtr.asFunction<void Function()>();
  1663. /// Push a `py_Name` to the stack. This is used for keyword arguments.
  1664. void py_pushname(
  1665. py_Name name,
  1666. ) {
  1667. return _py_pushname(
  1668. name,
  1669. );
  1670. }
  1671. late final _py_pushnamePtr =
  1672. _lookup<ffi.NativeFunction<ffi.Void Function(py_Name)>>('py_pushname');
  1673. late final _py_pushname =
  1674. _py_pushnamePtr.asFunction<void Function(py_Name)>();
  1675. /// Pop an object from the stack.
  1676. void py_pop() {
  1677. return _py_pop();
  1678. }
  1679. late final _py_popPtr =
  1680. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_pop');
  1681. late final _py_pop = _py_popPtr.asFunction<void Function()>();
  1682. /// Shrink the stack by n.
  1683. void py_shrink(
  1684. int n,
  1685. ) {
  1686. return _py_shrink(
  1687. n,
  1688. );
  1689. }
  1690. late final _py_shrinkPtr =
  1691. _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int)>>('py_shrink');
  1692. late final _py_shrink = _py_shrinkPtr.asFunction<void Function(int)>();
  1693. /// Get a temporary variable from the stack.
  1694. py_StackRef py_pushtmp() {
  1695. return _py_pushtmp();
  1696. }
  1697. late final _py_pushtmpPtr =
  1698. _lookup<ffi.NativeFunction<py_StackRef Function()>>('py_pushtmp');
  1699. late final _py_pushtmp = _py_pushtmpPtr.asFunction<py_StackRef Function()>();
  1700. /// Get the unbound method of the object.
  1701. /// Assume the object is located at the top of the stack.
  1702. /// If return true: `[self] -> [unbound, self]`.
  1703. /// If return false: `[self] -> [self]` (no change).
  1704. bool py_pushmethod(
  1705. py_Name name,
  1706. ) {
  1707. return _py_pushmethod(
  1708. name,
  1709. );
  1710. }
  1711. late final _py_pushmethodPtr =
  1712. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Name)>>('py_pushmethod');
  1713. late final _py_pushmethod =
  1714. _py_pushmethodPtr.asFunction<bool Function(py_Name)>();
  1715. /// Evaluate an expression and push the result to the stack.
  1716. /// This function is used for testing.
  1717. bool py_pusheval(
  1718. ffi.Pointer<ffi.Char> expr,
  1719. py_GlobalRef module,
  1720. ) {
  1721. return _py_pusheval(
  1722. expr,
  1723. module,
  1724. );
  1725. }
  1726. late final _py_pushevalPtr = _lookup<
  1727. ffi.NativeFunction<
  1728. ffi.Bool Function(
  1729. ffi.Pointer<ffi.Char>, py_GlobalRef)>>('py_pusheval');
  1730. late final _py_pusheval = _py_pushevalPtr
  1731. .asFunction<bool Function(ffi.Pointer<ffi.Char>, py_GlobalRef)>();
  1732. /// Call a callable object via pocketpy's calling convention.
  1733. /// You need to prepare the stack using the following format:
  1734. /// `callable, self/nil, arg1, arg2, ..., k1, v1, k2, v2, ...`.
  1735. /// `argc` is the number of positional arguments excluding `self`.
  1736. /// `kwargc` is the number of keyword arguments.
  1737. /// The result will be set to `py_retval()`.
  1738. /// The stack size will be reduced by `2 + argc + kwargc * 2`.
  1739. bool py_vectorcall(
  1740. int argc,
  1741. int kwargc,
  1742. ) {
  1743. return _py_vectorcall(
  1744. argc,
  1745. kwargc,
  1746. );
  1747. }
  1748. late final _py_vectorcallPtr =
  1749. _lookup<ffi.NativeFunction<ffi.Bool Function(ffi.Uint16, ffi.Uint16)>>(
  1750. 'py_vectorcall');
  1751. late final _py_vectorcall =
  1752. _py_vectorcallPtr.asFunction<bool Function(int, int)>();
  1753. /// Call a function.
  1754. /// It prepares the stack and then performs a `vectorcall(argc, 0, false)`.
  1755. /// The result will be set to `py_retval()`.
  1756. /// The stack remains unchanged if successful.
  1757. bool py_call(
  1758. py_Ref f,
  1759. int argc,
  1760. py_Ref argv,
  1761. ) {
  1762. return _py_call(
  1763. f,
  1764. argc,
  1765. argv,
  1766. );
  1767. }
  1768. late final _py_callPtr =
  1769. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, ffi.Int, py_Ref)>>(
  1770. 'py_call');
  1771. late final _py_call =
  1772. _py_callPtr.asFunction<bool Function(py_Ref, int, py_Ref)>();
  1773. /// Call a type to create a new instance.
  1774. bool py_tpcall(
  1775. int type,
  1776. int argc,
  1777. py_Ref argv,
  1778. ) {
  1779. return _py_tpcall(
  1780. type,
  1781. argc,
  1782. argv,
  1783. );
  1784. }
  1785. late final _py_tpcallPtr =
  1786. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Type, ffi.Int, py_Ref)>>(
  1787. 'py_tpcall');
  1788. late final _py_tpcall =
  1789. _py_tpcallPtr.asFunction<bool Function(int, int, py_Ref)>();
  1790. /// Call a `py_CFunction` in a safe way.
  1791. /// This function does extra checks to help you debug `py_CFunction`.
  1792. bool py_callcfunc(
  1793. py_CFunction f,
  1794. int argc,
  1795. py_Ref argv,
  1796. ) {
  1797. return _py_callcfunc(
  1798. f,
  1799. argc,
  1800. argv,
  1801. );
  1802. }
  1803. late final _py_callcfuncPtr = _lookup<
  1804. ffi.NativeFunction<ffi.Bool Function(py_CFunction, ffi.Int, py_Ref)>>(
  1805. 'py_callcfunc');
  1806. late final _py_callcfunc =
  1807. _py_callcfuncPtr.asFunction<bool Function(py_CFunction, int, py_Ref)>();
  1808. /// Perform a binary operation.
  1809. /// The result will be set to `py_retval()`.
  1810. /// The stack remains unchanged after the operation.
  1811. bool py_binaryop(
  1812. py_Ref lhs,
  1813. py_Ref rhs,
  1814. py_Name op,
  1815. py_Name rop,
  1816. ) {
  1817. return _py_binaryop(
  1818. lhs,
  1819. rhs,
  1820. op,
  1821. rop,
  1822. );
  1823. }
  1824. late final _py_binaryopPtr = _lookup<
  1825. ffi.NativeFunction<
  1826. ffi.Bool Function(py_Ref, py_Ref, py_Name, py_Name)>>('py_binaryop');
  1827. late final _py_binaryop = _py_binaryopPtr
  1828. .asFunction<bool Function(py_Ref, py_Ref, py_Name, py_Name)>();
  1829. /// lhs + rhs
  1830. bool py_binaryadd(
  1831. py_Ref lhs,
  1832. py_Ref rhs,
  1833. ) {
  1834. return _py_binaryadd(
  1835. lhs,
  1836. rhs,
  1837. );
  1838. }
  1839. late final _py_binaryaddPtr =
  1840. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1841. 'py_binaryadd');
  1842. late final _py_binaryadd =
  1843. _py_binaryaddPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1844. /// lhs - rhs
  1845. bool py_binarysub(
  1846. py_Ref lhs,
  1847. py_Ref rhs,
  1848. ) {
  1849. return _py_binarysub(
  1850. lhs,
  1851. rhs,
  1852. );
  1853. }
  1854. late final _py_binarysubPtr =
  1855. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1856. 'py_binarysub');
  1857. late final _py_binarysub =
  1858. _py_binarysubPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1859. /// lhs * rhs
  1860. bool py_binarymul(
  1861. py_Ref lhs,
  1862. py_Ref rhs,
  1863. ) {
  1864. return _py_binarymul(
  1865. lhs,
  1866. rhs,
  1867. );
  1868. }
  1869. late final _py_binarymulPtr =
  1870. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1871. 'py_binarymul');
  1872. late final _py_binarymul =
  1873. _py_binarymulPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1874. /// lhs / rhs
  1875. bool py_binarytruediv(
  1876. py_Ref lhs,
  1877. py_Ref rhs,
  1878. ) {
  1879. return _py_binarytruediv(
  1880. lhs,
  1881. rhs,
  1882. );
  1883. }
  1884. late final _py_binarytruedivPtr =
  1885. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1886. 'py_binarytruediv');
  1887. late final _py_binarytruediv =
  1888. _py_binarytruedivPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1889. /// lhs // rhs
  1890. bool py_binaryfloordiv(
  1891. py_Ref lhs,
  1892. py_Ref rhs,
  1893. ) {
  1894. return _py_binaryfloordiv(
  1895. lhs,
  1896. rhs,
  1897. );
  1898. }
  1899. late final _py_binaryfloordivPtr =
  1900. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1901. 'py_binaryfloordiv');
  1902. late final _py_binaryfloordiv =
  1903. _py_binaryfloordivPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1904. /// lhs % rhs
  1905. bool py_binarymod(
  1906. py_Ref lhs,
  1907. py_Ref rhs,
  1908. ) {
  1909. return _py_binarymod(
  1910. lhs,
  1911. rhs,
  1912. );
  1913. }
  1914. late final _py_binarymodPtr =
  1915. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1916. 'py_binarymod');
  1917. late final _py_binarymod =
  1918. _py_binarymodPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1919. /// lhs ** rhs
  1920. bool py_binarypow(
  1921. py_Ref lhs,
  1922. py_Ref rhs,
  1923. ) {
  1924. return _py_binarypow(
  1925. lhs,
  1926. rhs,
  1927. );
  1928. }
  1929. late final _py_binarypowPtr =
  1930. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1931. 'py_binarypow');
  1932. late final _py_binarypow =
  1933. _py_binarypowPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1934. /// lhs << rhs
  1935. bool py_binarylshift(
  1936. py_Ref lhs,
  1937. py_Ref rhs,
  1938. ) {
  1939. return _py_binarylshift(
  1940. lhs,
  1941. rhs,
  1942. );
  1943. }
  1944. late final _py_binarylshiftPtr =
  1945. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1946. 'py_binarylshift');
  1947. late final _py_binarylshift =
  1948. _py_binarylshiftPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1949. /// lhs >> rhs
  1950. bool py_binaryrshift(
  1951. py_Ref lhs,
  1952. py_Ref rhs,
  1953. ) {
  1954. return _py_binaryrshift(
  1955. lhs,
  1956. rhs,
  1957. );
  1958. }
  1959. late final _py_binaryrshiftPtr =
  1960. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1961. 'py_binaryrshift');
  1962. late final _py_binaryrshift =
  1963. _py_binaryrshiftPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1964. /// lhs & rhs
  1965. bool py_binaryand(
  1966. py_Ref lhs,
  1967. py_Ref rhs,
  1968. ) {
  1969. return _py_binaryand(
  1970. lhs,
  1971. rhs,
  1972. );
  1973. }
  1974. late final _py_binaryandPtr =
  1975. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1976. 'py_binaryand');
  1977. late final _py_binaryand =
  1978. _py_binaryandPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1979. /// lhs | rhs
  1980. bool py_binaryor(
  1981. py_Ref lhs,
  1982. py_Ref rhs,
  1983. ) {
  1984. return _py_binaryor(
  1985. lhs,
  1986. rhs,
  1987. );
  1988. }
  1989. late final _py_binaryorPtr =
  1990. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1991. 'py_binaryor');
  1992. late final _py_binaryor =
  1993. _py_binaryorPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1994. /// lhs ^ rhs
  1995. bool py_binaryxor(
  1996. py_Ref lhs,
  1997. py_Ref rhs,
  1998. ) {
  1999. return _py_binaryxor(
  2000. lhs,
  2001. rhs,
  2002. );
  2003. }
  2004. late final _py_binaryxorPtr =
  2005. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  2006. 'py_binaryxor');
  2007. late final _py_binaryxor =
  2008. _py_binaryxorPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  2009. /// lhs @ rhs
  2010. bool py_binarymatmul(
  2011. py_Ref lhs,
  2012. py_Ref rhs,
  2013. ) {
  2014. return _py_binarymatmul(
  2015. lhs,
  2016. rhs,
  2017. );
  2018. }
  2019. late final _py_binarymatmulPtr =
  2020. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  2021. 'py_binarymatmul');
  2022. late final _py_binarymatmul =
  2023. _py_binarymatmulPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  2024. /// lhs == rhs
  2025. bool py_eq(
  2026. py_Ref lhs,
  2027. py_Ref rhs,
  2028. ) {
  2029. return _py_eq(
  2030. lhs,
  2031. rhs,
  2032. );
  2033. }
  2034. late final _py_eqPtr =
  2035. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>('py_eq');
  2036. late final _py_eq = _py_eqPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  2037. /// lhs != rhs
  2038. bool py_ne(
  2039. py_Ref lhs,
  2040. py_Ref rhs,
  2041. ) {
  2042. return _py_ne(
  2043. lhs,
  2044. rhs,
  2045. );
  2046. }
  2047. late final _py_nePtr =
  2048. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>('py_ne');
  2049. late final _py_ne = _py_nePtr.asFunction<bool Function(py_Ref, py_Ref)>();
  2050. /// lhs < rhs
  2051. bool py_lt(
  2052. py_Ref lhs,
  2053. py_Ref rhs,
  2054. ) {
  2055. return _py_lt(
  2056. lhs,
  2057. rhs,
  2058. );
  2059. }
  2060. late final _py_ltPtr =
  2061. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>('py_lt');
  2062. late final _py_lt = _py_ltPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  2063. /// lhs <= rhs
  2064. bool py_le(
  2065. py_Ref lhs,
  2066. py_Ref rhs,
  2067. ) {
  2068. return _py_le(
  2069. lhs,
  2070. rhs,
  2071. );
  2072. }
  2073. late final _py_lePtr =
  2074. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>('py_le');
  2075. late final _py_le = _py_lePtr.asFunction<bool Function(py_Ref, py_Ref)>();
  2076. /// lhs > rhs
  2077. bool py_gt(
  2078. py_Ref lhs,
  2079. py_Ref rhs,
  2080. ) {
  2081. return _py_gt(
  2082. lhs,
  2083. rhs,
  2084. );
  2085. }
  2086. late final _py_gtPtr =
  2087. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>('py_gt');
  2088. late final _py_gt = _py_gtPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  2089. /// lhs >= rhs
  2090. bool py_ge(
  2091. py_Ref lhs,
  2092. py_Ref rhs,
  2093. ) {
  2094. return _py_ge(
  2095. lhs,
  2096. rhs,
  2097. );
  2098. }
  2099. late final _py_gePtr =
  2100. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>('py_ge');
  2101. late final _py_ge = _py_gePtr.asFunction<bool Function(py_Ref, py_Ref)>();
  2102. /// Python equivalent to `lhs is rhs`.
  2103. bool py_isidentical(
  2104. py_Ref arg0,
  2105. py_Ref arg1,
  2106. ) {
  2107. return _py_isidentical(
  2108. arg0,
  2109. arg1,
  2110. );
  2111. }
  2112. late final _py_isidenticalPtr =
  2113. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  2114. 'py_isidentical');
  2115. late final _py_isidentical =
  2116. _py_isidenticalPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  2117. /// Python equivalent to `bool(val)`.
  2118. /// 1: true, 0: false, -1: error
  2119. int py_bool(
  2120. py_Ref val,
  2121. ) {
  2122. return _py_bool(
  2123. val,
  2124. );
  2125. }
  2126. late final _py_boolPtr =
  2127. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref)>>('py_bool');
  2128. late final _py_bool = _py_boolPtr.asFunction<int Function(py_Ref)>();
  2129. /// Compare two objects.
  2130. /// 1: lhs == rhs, 0: lhs != rhs, -1: error
  2131. int py_equal(
  2132. py_Ref lhs,
  2133. py_Ref rhs,
  2134. ) {
  2135. return _py_equal(
  2136. lhs,
  2137. rhs,
  2138. );
  2139. }
  2140. late final _py_equalPtr =
  2141. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref, py_Ref)>>('py_equal');
  2142. late final _py_equal =
  2143. _py_equalPtr.asFunction<int Function(py_Ref, py_Ref)>();
  2144. /// Compare two objects.
  2145. /// 1: lhs < rhs, 0: lhs >= rhs, -1: error
  2146. int py_less(
  2147. py_Ref lhs,
  2148. py_Ref rhs,
  2149. ) {
  2150. return _py_less(
  2151. lhs,
  2152. rhs,
  2153. );
  2154. }
  2155. late final _py_lessPtr =
  2156. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref, py_Ref)>>('py_less');
  2157. late final _py_less = _py_lessPtr.asFunction<int Function(py_Ref, py_Ref)>();
  2158. /// Python equivalent to `callable(val)`.
  2159. bool py_callable(
  2160. py_Ref val,
  2161. ) {
  2162. return _py_callable(
  2163. val,
  2164. );
  2165. }
  2166. late final _py_callablePtr =
  2167. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_callable');
  2168. late final _py_callable = _py_callablePtr.asFunction<bool Function(py_Ref)>();
  2169. /// Get the hash value of the object.
  2170. bool py_hash(
  2171. py_Ref arg0,
  2172. ffi.Pointer<py_i64> out,
  2173. ) {
  2174. return _py_hash(
  2175. arg0,
  2176. out,
  2177. );
  2178. }
  2179. late final _py_hashPtr = _lookup<
  2180. ffi.NativeFunction<ffi.Bool Function(py_Ref, ffi.Pointer<py_i64>)>>(
  2181. 'py_hash');
  2182. late final _py_hash =
  2183. _py_hashPtr.asFunction<bool Function(py_Ref, ffi.Pointer<py_i64>)>();
  2184. /// Get the iterator of the object.
  2185. bool py_iter(
  2186. py_Ref arg0,
  2187. ) {
  2188. return _py_iter(
  2189. arg0,
  2190. );
  2191. }
  2192. late final _py_iterPtr =
  2193. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_iter');
  2194. late final _py_iter = _py_iterPtr.asFunction<bool Function(py_Ref)>();
  2195. /// Get the next element from the iterator.
  2196. /// 1: success, 0: StopIteration, -1: error
  2197. int py_next(
  2198. py_Ref arg0,
  2199. ) {
  2200. return _py_next(
  2201. arg0,
  2202. );
  2203. }
  2204. late final _py_nextPtr =
  2205. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref)>>('py_next');
  2206. late final _py_next = _py_nextPtr.asFunction<int Function(py_Ref)>();
  2207. /// Python equivalent to `str(val)`.
  2208. bool py_str(
  2209. py_Ref val,
  2210. ) {
  2211. return _py_str(
  2212. val,
  2213. );
  2214. }
  2215. late final _py_strPtr =
  2216. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_str');
  2217. late final _py_str = _py_strPtr.asFunction<bool Function(py_Ref)>();
  2218. /// Python equivalent to `repr(val)`.
  2219. bool py_repr(
  2220. py_Ref val,
  2221. ) {
  2222. return _py_repr(
  2223. val,
  2224. );
  2225. }
  2226. late final _py_reprPtr =
  2227. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_repr');
  2228. late final _py_repr = _py_reprPtr.asFunction<bool Function(py_Ref)>();
  2229. /// Python equivalent to `len(val)`.
  2230. bool py_len(
  2231. py_Ref val,
  2232. ) {
  2233. return _py_len(
  2234. val,
  2235. );
  2236. }
  2237. late final _py_lenPtr =
  2238. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_len');
  2239. late final _py_len = _py_lenPtr.asFunction<bool Function(py_Ref)>();
  2240. /// Python equivalent to `getattr(self, name)`.
  2241. bool py_getattr(
  2242. py_Ref self,
  2243. py_Name name,
  2244. ) {
  2245. return _py_getattr(
  2246. self,
  2247. name,
  2248. );
  2249. }
  2250. late final _py_getattrPtr =
  2251. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Name)>>(
  2252. 'py_getattr');
  2253. late final _py_getattr =
  2254. _py_getattrPtr.asFunction<bool Function(py_Ref, py_Name)>();
  2255. /// Python equivalent to `setattr(self, name, val)`.
  2256. bool py_setattr(
  2257. py_Ref self,
  2258. py_Name name,
  2259. py_Ref val,
  2260. ) {
  2261. return _py_setattr(
  2262. self,
  2263. name,
  2264. val,
  2265. );
  2266. }
  2267. late final _py_setattrPtr =
  2268. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Name, py_Ref)>>(
  2269. 'py_setattr');
  2270. late final _py_setattr =
  2271. _py_setattrPtr.asFunction<bool Function(py_Ref, py_Name, py_Ref)>();
  2272. /// Python equivalent to `delattr(self, name)`.
  2273. bool py_delattr(
  2274. py_Ref self,
  2275. py_Name name,
  2276. ) {
  2277. return _py_delattr(
  2278. self,
  2279. name,
  2280. );
  2281. }
  2282. late final _py_delattrPtr =
  2283. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Name)>>(
  2284. 'py_delattr');
  2285. late final _py_delattr =
  2286. _py_delattrPtr.asFunction<bool Function(py_Ref, py_Name)>();
  2287. /// Python equivalent to `self[key]`.
  2288. bool py_getitem(
  2289. py_Ref self,
  2290. py_Ref key,
  2291. ) {
  2292. return _py_getitem(
  2293. self,
  2294. key,
  2295. );
  2296. }
  2297. late final _py_getitemPtr =
  2298. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  2299. 'py_getitem');
  2300. late final _py_getitem =
  2301. _py_getitemPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  2302. /// Python equivalent to `self[key] = val`.
  2303. bool py_setitem(
  2304. py_Ref self,
  2305. py_Ref key,
  2306. py_Ref val,
  2307. ) {
  2308. return _py_setitem(
  2309. self,
  2310. key,
  2311. val,
  2312. );
  2313. }
  2314. late final _py_setitemPtr =
  2315. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref, py_Ref)>>(
  2316. 'py_setitem');
  2317. late final _py_setitem =
  2318. _py_setitemPtr.asFunction<bool Function(py_Ref, py_Ref, py_Ref)>();
  2319. /// Python equivalent to `del self[key]`.
  2320. bool py_delitem(
  2321. py_Ref self,
  2322. py_Ref key,
  2323. ) {
  2324. return _py_delitem(
  2325. self,
  2326. key,
  2327. );
  2328. }
  2329. late final _py_delitemPtr =
  2330. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  2331. 'py_delitem');
  2332. late final _py_delitem =
  2333. _py_delitemPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  2334. /// Get a module by path.
  2335. py_GlobalRef py_getmodule(
  2336. ffi.Pointer<ffi.Char> path,
  2337. ) {
  2338. return _py_getmodule(
  2339. path,
  2340. );
  2341. }
  2342. late final _py_getmodulePtr =
  2343. _lookup<ffi.NativeFunction<py_GlobalRef Function(ffi.Pointer<ffi.Char>)>>(
  2344. 'py_getmodule');
  2345. late final _py_getmodule = _py_getmodulePtr
  2346. .asFunction<py_GlobalRef Function(ffi.Pointer<ffi.Char>)>();
  2347. /// Create a new module.
  2348. py_GlobalRef py_newmodule(
  2349. ffi.Pointer<ffi.Char> path,
  2350. ) {
  2351. return _py_newmodule(
  2352. path,
  2353. );
  2354. }
  2355. late final _py_newmodulePtr =
  2356. _lookup<ffi.NativeFunction<py_GlobalRef Function(ffi.Pointer<ffi.Char>)>>(
  2357. 'py_newmodule');
  2358. late final _py_newmodule = _py_newmodulePtr
  2359. .asFunction<py_GlobalRef Function(ffi.Pointer<ffi.Char>)>();
  2360. /// Reload an existing module.
  2361. bool py_importlib_reload(
  2362. py_Ref module,
  2363. ) {
  2364. return _py_importlib_reload(
  2365. module,
  2366. );
  2367. }
  2368. late final _py_importlib_reloadPtr =
  2369. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>(
  2370. 'py_importlib_reload');
  2371. late final _py_importlib_reload =
  2372. _py_importlib_reloadPtr.asFunction<bool Function(py_Ref)>();
  2373. /// Import a module.
  2374. /// The result will be set to `py_retval()`.
  2375. /// -1: error, 0: not found, 1: success
  2376. int py_import(
  2377. ffi.Pointer<ffi.Char> path,
  2378. ) {
  2379. return _py_import(
  2380. path,
  2381. );
  2382. }
  2383. late final _py_importPtr =
  2384. _lookup<ffi.NativeFunction<ffi.Int Function(ffi.Pointer<ffi.Char>)>>(
  2385. 'py_import');
  2386. late final _py_import =
  2387. _py_importPtr.asFunction<int Function(ffi.Pointer<ffi.Char>)>();
  2388. /// Check if there is an unhandled exception.
  2389. bool py_checkexc() {
  2390. return _py_checkexc();
  2391. }
  2392. late final _py_checkexcPtr =
  2393. _lookup<ffi.NativeFunction<ffi.Bool Function()>>('py_checkexc');
  2394. late final _py_checkexc = _py_checkexcPtr.asFunction<bool Function()>();
  2395. /// Check if the unhandled exception is an instance of the given type.
  2396. /// If match, the exception will be stored in `py_retval()`.
  2397. bool py_matchexc(
  2398. int type,
  2399. ) {
  2400. return _py_matchexc(
  2401. type,
  2402. );
  2403. }
  2404. late final _py_matchexcPtr =
  2405. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Type)>>('py_matchexc');
  2406. late final _py_matchexc = _py_matchexcPtr.asFunction<bool Function(int)>();
  2407. /// Clear the unhandled exception.
  2408. /// @param p0 the unwinding point. Use `NULL` if not needed.
  2409. void py_clearexc(
  2410. py_StackRef p0,
  2411. ) {
  2412. return _py_clearexc(
  2413. p0,
  2414. );
  2415. }
  2416. late final _py_clearexcPtr =
  2417. _lookup<ffi.NativeFunction<ffi.Void Function(py_StackRef)>>(
  2418. 'py_clearexc');
  2419. late final _py_clearexc =
  2420. _py_clearexcPtr.asFunction<void Function(py_StackRef)>();
  2421. /// Print the unhandled exception.
  2422. void py_printexc() {
  2423. return _py_printexc();
  2424. }
  2425. late final _py_printexcPtr =
  2426. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_printexc');
  2427. late final _py_printexc = _py_printexcPtr.asFunction<void Function()>();
  2428. /// Format the unhandled exception and return a null-terminated string.
  2429. /// The returned string should be freed by the caller.
  2430. ffi.Pointer<ffi.Char> py_formatexc() {
  2431. return _py_formatexc();
  2432. }
  2433. late final _py_formatexcPtr =
  2434. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
  2435. 'py_formatexc');
  2436. late final _py_formatexc =
  2437. _py_formatexcPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
  2438. /// Raise an exception by type and message. Always return false.
  2439. bool py_exception(
  2440. int type,
  2441. ffi.Pointer<ffi.Char> fmt,
  2442. ) {
  2443. return _py_exception(
  2444. type,
  2445. fmt,
  2446. );
  2447. }
  2448. late final _py_exceptionPtr = _lookup<
  2449. ffi.NativeFunction<
  2450. ffi.Bool Function(py_Type, ffi.Pointer<ffi.Char>)>>('py_exception');
  2451. late final _py_exception =
  2452. _py_exceptionPtr.asFunction<bool Function(int, ffi.Pointer<ffi.Char>)>();
  2453. /// Raise an exception object. Always return false.
  2454. bool py_raise(
  2455. py_Ref arg0,
  2456. ) {
  2457. return _py_raise(
  2458. arg0,
  2459. );
  2460. }
  2461. late final _py_raisePtr =
  2462. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_raise');
  2463. late final _py_raise = _py_raisePtr.asFunction<bool Function(py_Ref)>();
  2464. bool KeyError(
  2465. py_Ref key,
  2466. ) {
  2467. return _KeyError(
  2468. key,
  2469. );
  2470. }
  2471. late final _KeyErrorPtr =
  2472. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('KeyError');
  2473. late final _KeyError = _KeyErrorPtr.asFunction<bool Function(py_Ref)>();
  2474. bool StopIteration() {
  2475. return _StopIteration();
  2476. }
  2477. late final _StopIterationPtr =
  2478. _lookup<ffi.NativeFunction<ffi.Bool Function()>>('StopIteration');
  2479. late final _StopIteration = _StopIterationPtr.asFunction<bool Function()>();
  2480. void py_debugger_waitforattach(
  2481. ffi.Pointer<ffi.Char> hostname,
  2482. int port,
  2483. ) {
  2484. return _py_debugger_waitforattach(
  2485. hostname,
  2486. port,
  2487. );
  2488. }
  2489. late final _py_debugger_waitforattachPtr = _lookup<
  2490. ffi.NativeFunction<
  2491. ffi.Void Function(ffi.Pointer<ffi.Char>,
  2492. ffi.UnsignedShort)>>('py_debugger_waitforattach');
  2493. late final _py_debugger_waitforattach = _py_debugger_waitforattachPtr
  2494. .asFunction<void Function(ffi.Pointer<ffi.Char>, int)>();
  2495. int py_debugger_status() {
  2496. return _py_debugger_status();
  2497. }
  2498. late final _py_debugger_statusPtr =
  2499. _lookup<ffi.NativeFunction<ffi.Int Function()>>('py_debugger_status');
  2500. late final _py_debugger_status =
  2501. _py_debugger_statusPtr.asFunction<int Function()>();
  2502. void py_debugger_exceptionbreakpoint(
  2503. py_Ref exc,
  2504. ) {
  2505. return _py_debugger_exceptionbreakpoint(
  2506. exc,
  2507. );
  2508. }
  2509. late final _py_debugger_exceptionbreakpointPtr =
  2510. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref)>>(
  2511. 'py_debugger_exceptionbreakpoint');
  2512. late final _py_debugger_exceptionbreakpoint =
  2513. _py_debugger_exceptionbreakpointPtr.asFunction<void Function(py_Ref)>();
  2514. void py_debugger_exit(
  2515. int code,
  2516. ) {
  2517. return _py_debugger_exit(
  2518. code,
  2519. );
  2520. }
  2521. late final _py_debugger_exitPtr =
  2522. _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int)>>(
  2523. 'py_debugger_exit');
  2524. late final _py_debugger_exit =
  2525. _py_debugger_exitPtr.asFunction<void Function(int)>();
  2526. /// Create a `tuple` with `n` UNINITIALIZED elements.
  2527. /// You should initialize all elements before using it.
  2528. py_ObjectRef py_newtuple(
  2529. py_OutRef arg0,
  2530. int n,
  2531. ) {
  2532. return _py_newtuple(
  2533. arg0,
  2534. n,
  2535. );
  2536. }
  2537. late final _py_newtuplePtr =
  2538. _lookup<ffi.NativeFunction<py_ObjectRef Function(py_OutRef, ffi.Int)>>(
  2539. 'py_newtuple');
  2540. late final _py_newtuple =
  2541. _py_newtuplePtr.asFunction<py_ObjectRef Function(py_OutRef, int)>();
  2542. py_ObjectRef py_tuple_data(
  2543. py_Ref self,
  2544. ) {
  2545. return _py_tuple_data(
  2546. self,
  2547. );
  2548. }
  2549. late final _py_tuple_dataPtr =
  2550. _lookup<ffi.NativeFunction<py_ObjectRef Function(py_Ref)>>(
  2551. 'py_tuple_data');
  2552. late final _py_tuple_data =
  2553. _py_tuple_dataPtr.asFunction<py_ObjectRef Function(py_Ref)>();
  2554. py_ObjectRef py_tuple_getitem(
  2555. py_Ref self,
  2556. int i,
  2557. ) {
  2558. return _py_tuple_getitem(
  2559. self,
  2560. i,
  2561. );
  2562. }
  2563. late final _py_tuple_getitemPtr =
  2564. _lookup<ffi.NativeFunction<py_ObjectRef Function(py_Ref, ffi.Int)>>(
  2565. 'py_tuple_getitem');
  2566. late final _py_tuple_getitem =
  2567. _py_tuple_getitemPtr.asFunction<py_ObjectRef Function(py_Ref, int)>();
  2568. void py_tuple_setitem(
  2569. py_Ref self,
  2570. int i,
  2571. py_Ref val,
  2572. ) {
  2573. return _py_tuple_setitem(
  2574. self,
  2575. i,
  2576. val,
  2577. );
  2578. }
  2579. late final _py_tuple_setitemPtr =
  2580. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int, py_Ref)>>(
  2581. 'py_tuple_setitem');
  2582. late final _py_tuple_setitem =
  2583. _py_tuple_setitemPtr.asFunction<void Function(py_Ref, int, py_Ref)>();
  2584. int py_tuple_len(
  2585. py_Ref self,
  2586. ) {
  2587. return _py_tuple_len(
  2588. self,
  2589. );
  2590. }
  2591. late final _py_tuple_lenPtr =
  2592. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref)>>('py_tuple_len');
  2593. late final _py_tuple_len =
  2594. _py_tuple_lenPtr.asFunction<int Function(py_Ref)>();
  2595. /// Create an empty `list`.
  2596. void py_newlist(
  2597. py_OutRef arg0,
  2598. ) {
  2599. return _py_newlist(
  2600. arg0,
  2601. );
  2602. }
  2603. late final _py_newlistPtr =
  2604. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>('py_newlist');
  2605. late final _py_newlist =
  2606. _py_newlistPtr.asFunction<void Function(py_OutRef)>();
  2607. /// Create a `list` with `n` UNINITIALIZED elements.
  2608. /// You should initialize all elements before using it.
  2609. void py_newlistn(
  2610. py_OutRef arg0,
  2611. int n,
  2612. ) {
  2613. return _py_newlistn(
  2614. arg0,
  2615. n,
  2616. );
  2617. }
  2618. late final _py_newlistnPtr =
  2619. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, ffi.Int)>>(
  2620. 'py_newlistn');
  2621. late final _py_newlistn =
  2622. _py_newlistnPtr.asFunction<void Function(py_OutRef, int)>();
  2623. py_ItemRef py_list_data(
  2624. py_Ref self,
  2625. ) {
  2626. return _py_list_data(
  2627. self,
  2628. );
  2629. }
  2630. late final _py_list_dataPtr =
  2631. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Ref)>>('py_list_data');
  2632. late final _py_list_data =
  2633. _py_list_dataPtr.asFunction<py_ItemRef Function(py_Ref)>();
  2634. py_ItemRef py_list_getitem(
  2635. py_Ref self,
  2636. int i,
  2637. ) {
  2638. return _py_list_getitem(
  2639. self,
  2640. i,
  2641. );
  2642. }
  2643. late final _py_list_getitemPtr =
  2644. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Ref, ffi.Int)>>(
  2645. 'py_list_getitem');
  2646. late final _py_list_getitem =
  2647. _py_list_getitemPtr.asFunction<py_ItemRef Function(py_Ref, int)>();
  2648. void py_list_setitem(
  2649. py_Ref self,
  2650. int i,
  2651. py_Ref val,
  2652. ) {
  2653. return _py_list_setitem(
  2654. self,
  2655. i,
  2656. val,
  2657. );
  2658. }
  2659. late final _py_list_setitemPtr =
  2660. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int, py_Ref)>>(
  2661. 'py_list_setitem');
  2662. late final _py_list_setitem =
  2663. _py_list_setitemPtr.asFunction<void Function(py_Ref, int, py_Ref)>();
  2664. void py_list_delitem(
  2665. py_Ref self,
  2666. int i,
  2667. ) {
  2668. return _py_list_delitem(
  2669. self,
  2670. i,
  2671. );
  2672. }
  2673. late final _py_list_delitemPtr =
  2674. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int)>>(
  2675. 'py_list_delitem');
  2676. late final _py_list_delitem =
  2677. _py_list_delitemPtr.asFunction<void Function(py_Ref, int)>();
  2678. int py_list_len(
  2679. py_Ref self,
  2680. ) {
  2681. return _py_list_len(
  2682. self,
  2683. );
  2684. }
  2685. late final _py_list_lenPtr =
  2686. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref)>>('py_list_len');
  2687. late final _py_list_len = _py_list_lenPtr.asFunction<int Function(py_Ref)>();
  2688. void py_list_swap(
  2689. py_Ref self,
  2690. int i,
  2691. int j,
  2692. ) {
  2693. return _py_list_swap(
  2694. self,
  2695. i,
  2696. j,
  2697. );
  2698. }
  2699. late final _py_list_swapPtr =
  2700. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int, ffi.Int)>>(
  2701. 'py_list_swap');
  2702. late final _py_list_swap =
  2703. _py_list_swapPtr.asFunction<void Function(py_Ref, int, int)>();
  2704. void py_list_append(
  2705. py_Ref self,
  2706. py_Ref val,
  2707. ) {
  2708. return _py_list_append(
  2709. self,
  2710. val,
  2711. );
  2712. }
  2713. late final _py_list_appendPtr =
  2714. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, py_Ref)>>(
  2715. 'py_list_append');
  2716. late final _py_list_append =
  2717. _py_list_appendPtr.asFunction<void Function(py_Ref, py_Ref)>();
  2718. py_ItemRef py_list_emplace(
  2719. py_Ref self,
  2720. ) {
  2721. return _py_list_emplace(
  2722. self,
  2723. );
  2724. }
  2725. late final _py_list_emplacePtr =
  2726. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Ref)>>(
  2727. 'py_list_emplace');
  2728. late final _py_list_emplace =
  2729. _py_list_emplacePtr.asFunction<py_ItemRef Function(py_Ref)>();
  2730. void py_list_clear(
  2731. py_Ref self,
  2732. ) {
  2733. return _py_list_clear(
  2734. self,
  2735. );
  2736. }
  2737. late final _py_list_clearPtr =
  2738. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref)>>('py_list_clear');
  2739. late final _py_list_clear =
  2740. _py_list_clearPtr.asFunction<void Function(py_Ref)>();
  2741. void py_list_insert(
  2742. py_Ref self,
  2743. int i,
  2744. py_Ref val,
  2745. ) {
  2746. return _py_list_insert(
  2747. self,
  2748. i,
  2749. val,
  2750. );
  2751. }
  2752. late final _py_list_insertPtr =
  2753. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int, py_Ref)>>(
  2754. 'py_list_insert');
  2755. late final _py_list_insert =
  2756. _py_list_insertPtr.asFunction<void Function(py_Ref, int, py_Ref)>();
  2757. /// Create an empty `dict`.
  2758. void py_newdict(
  2759. py_OutRef arg0,
  2760. ) {
  2761. return _py_newdict(
  2762. arg0,
  2763. );
  2764. }
  2765. late final _py_newdictPtr =
  2766. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>('py_newdict');
  2767. late final _py_newdict =
  2768. _py_newdictPtr.asFunction<void Function(py_OutRef)>();
  2769. /// -1: error, 0: not found, 1: found
  2770. int py_dict_getitem(
  2771. py_Ref self,
  2772. py_Ref key,
  2773. ) {
  2774. return _py_dict_getitem(
  2775. self,
  2776. key,
  2777. );
  2778. }
  2779. late final _py_dict_getitemPtr =
  2780. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref, py_Ref)>>(
  2781. 'py_dict_getitem');
  2782. late final _py_dict_getitem =
  2783. _py_dict_getitemPtr.asFunction<int Function(py_Ref, py_Ref)>();
  2784. /// true: success, false: error
  2785. bool py_dict_setitem(
  2786. py_Ref self,
  2787. py_Ref key,
  2788. py_Ref val,
  2789. ) {
  2790. return _py_dict_setitem(
  2791. self,
  2792. key,
  2793. val,
  2794. );
  2795. }
  2796. late final _py_dict_setitemPtr =
  2797. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref, py_Ref)>>(
  2798. 'py_dict_setitem');
  2799. late final _py_dict_setitem =
  2800. _py_dict_setitemPtr.asFunction<bool Function(py_Ref, py_Ref, py_Ref)>();
  2801. /// -1: error, 0: not found, 1: found (and deleted)
  2802. int py_dict_delitem(
  2803. py_Ref self,
  2804. py_Ref key,
  2805. ) {
  2806. return _py_dict_delitem(
  2807. self,
  2808. key,
  2809. );
  2810. }
  2811. late final _py_dict_delitemPtr =
  2812. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref, py_Ref)>>(
  2813. 'py_dict_delitem');
  2814. late final _py_dict_delitem =
  2815. _py_dict_delitemPtr.asFunction<int Function(py_Ref, py_Ref)>();
  2816. /// -1: error, 0: not found, 1: found
  2817. int py_dict_getitem_by_str(
  2818. py_Ref self,
  2819. ffi.Pointer<ffi.Char> key,
  2820. ) {
  2821. return _py_dict_getitem_by_str(
  2822. self,
  2823. key,
  2824. );
  2825. }
  2826. late final _py_dict_getitem_by_strPtr = _lookup<
  2827. ffi.NativeFunction<ffi.Int Function(py_Ref, ffi.Pointer<ffi.Char>)>>(
  2828. 'py_dict_getitem_by_str');
  2829. late final _py_dict_getitem_by_str = _py_dict_getitem_by_strPtr
  2830. .asFunction<int Function(py_Ref, ffi.Pointer<ffi.Char>)>();
  2831. /// -1: error, 0: not found, 1: found
  2832. int py_dict_getitem_by_int(
  2833. py_Ref self,
  2834. int key,
  2835. ) {
  2836. return _py_dict_getitem_by_int(
  2837. self,
  2838. key,
  2839. );
  2840. }
  2841. late final _py_dict_getitem_by_intPtr =
  2842. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref, py_i64)>>(
  2843. 'py_dict_getitem_by_int');
  2844. late final _py_dict_getitem_by_int =
  2845. _py_dict_getitem_by_intPtr.asFunction<int Function(py_Ref, int)>();
  2846. /// true: success, false: error
  2847. bool py_dict_setitem_by_str(
  2848. py_Ref self,
  2849. ffi.Pointer<ffi.Char> key,
  2850. py_Ref val,
  2851. ) {
  2852. return _py_dict_setitem_by_str(
  2853. self,
  2854. key,
  2855. val,
  2856. );
  2857. }
  2858. late final _py_dict_setitem_by_strPtr = _lookup<
  2859. ffi.NativeFunction<
  2860. ffi.Bool Function(py_Ref, ffi.Pointer<ffi.Char>,
  2861. py_Ref)>>('py_dict_setitem_by_str');
  2862. late final _py_dict_setitem_by_str = _py_dict_setitem_by_strPtr
  2863. .asFunction<bool Function(py_Ref, ffi.Pointer<ffi.Char>, py_Ref)>();
  2864. /// true: success, false: error
  2865. bool py_dict_setitem_by_int(
  2866. py_Ref self,
  2867. int key,
  2868. py_Ref val,
  2869. ) {
  2870. return _py_dict_setitem_by_int(
  2871. self,
  2872. key,
  2873. val,
  2874. );
  2875. }
  2876. late final _py_dict_setitem_by_intPtr =
  2877. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_i64, py_Ref)>>(
  2878. 'py_dict_setitem_by_int');
  2879. late final _py_dict_setitem_by_int = _py_dict_setitem_by_intPtr
  2880. .asFunction<bool Function(py_Ref, int, py_Ref)>();
  2881. /// -1: error, 0: not found, 1: found (and deleted)
  2882. int py_dict_delitem_by_str(
  2883. py_Ref self,
  2884. ffi.Pointer<ffi.Char> key,
  2885. ) {
  2886. return _py_dict_delitem_by_str(
  2887. self,
  2888. key,
  2889. );
  2890. }
  2891. late final _py_dict_delitem_by_strPtr = _lookup<
  2892. ffi.NativeFunction<ffi.Int Function(py_Ref, ffi.Pointer<ffi.Char>)>>(
  2893. 'py_dict_delitem_by_str');
  2894. late final _py_dict_delitem_by_str = _py_dict_delitem_by_strPtr
  2895. .asFunction<int Function(py_Ref, ffi.Pointer<ffi.Char>)>();
  2896. /// -1: error, 0: not found, 1: found (and deleted)
  2897. int py_dict_delitem_by_int(
  2898. py_Ref self,
  2899. int key,
  2900. ) {
  2901. return _py_dict_delitem_by_int(
  2902. self,
  2903. key,
  2904. );
  2905. }
  2906. late final _py_dict_delitem_by_intPtr =
  2907. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref, py_i64)>>(
  2908. 'py_dict_delitem_by_int');
  2909. late final _py_dict_delitem_by_int =
  2910. _py_dict_delitem_by_intPtr.asFunction<int Function(py_Ref, int)>();
  2911. /// true: success, false: error
  2912. bool py_dict_apply(
  2913. py_Ref self,
  2914. ffi.Pointer<
  2915. ffi.NativeFunction<
  2916. ffi.Bool Function(
  2917. py_Ref key, py_Ref val, ffi.Pointer<ffi.Void> ctx)>>
  2918. f,
  2919. ffi.Pointer<ffi.Void> ctx,
  2920. ) {
  2921. return _py_dict_apply(
  2922. self,
  2923. f,
  2924. ctx,
  2925. );
  2926. }
  2927. late final _py_dict_applyPtr = _lookup<
  2928. ffi.NativeFunction<
  2929. ffi.Bool Function(
  2930. py_Ref,
  2931. ffi.Pointer<
  2932. ffi.NativeFunction<
  2933. ffi.Bool Function(
  2934. py_Ref key, py_Ref val, ffi.Pointer<ffi.Void> ctx)>>,
  2935. ffi.Pointer<ffi.Void>)>>('py_dict_apply');
  2936. late final _py_dict_apply = _py_dict_applyPtr.asFunction<
  2937. bool Function(
  2938. py_Ref,
  2939. ffi.Pointer<
  2940. ffi.NativeFunction<
  2941. ffi.Bool Function(
  2942. py_Ref key, py_Ref val, ffi.Pointer<ffi.Void> ctx)>>,
  2943. ffi.Pointer<ffi.Void>)>();
  2944. /// noexcept
  2945. int py_dict_len(
  2946. py_Ref self,
  2947. ) {
  2948. return _py_dict_len(
  2949. self,
  2950. );
  2951. }
  2952. late final _py_dict_lenPtr =
  2953. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref)>>('py_dict_len');
  2954. late final _py_dict_len = _py_dict_lenPtr.asFunction<int Function(py_Ref)>();
  2955. /// Create an UNINITIALIZED `slice` object.
  2956. /// You should use `py_setslot()` to set `start`, `stop`, and `step`.
  2957. py_ObjectRef py_newslice(
  2958. py_OutRef arg0,
  2959. ) {
  2960. return _py_newslice(
  2961. arg0,
  2962. );
  2963. }
  2964. late final _py_newslicePtr =
  2965. _lookup<ffi.NativeFunction<py_ObjectRef Function(py_OutRef)>>(
  2966. 'py_newslice');
  2967. late final _py_newslice =
  2968. _py_newslicePtr.asFunction<py_ObjectRef Function(py_OutRef)>();
  2969. /// Create a `slice` object from 3 integers.
  2970. void py_newsliceint(
  2971. py_OutRef out,
  2972. int start,
  2973. int stop,
  2974. int step,
  2975. ) {
  2976. return _py_newsliceint(
  2977. out,
  2978. start,
  2979. stop,
  2980. step,
  2981. );
  2982. }
  2983. late final _py_newsliceintPtr = _lookup<
  2984. ffi.NativeFunction<
  2985. ffi.Void Function(
  2986. py_OutRef, py_i64, py_i64, py_i64)>>('py_newsliceint');
  2987. late final _py_newsliceint =
  2988. _py_newsliceintPtr.asFunction<void Function(py_OutRef, int, int, int)>();
  2989. /// random module
  2990. void py_newRandom(
  2991. py_OutRef out,
  2992. ) {
  2993. return _py_newRandom(
  2994. out,
  2995. );
  2996. }
  2997. late final _py_newRandomPtr =
  2998. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>('py_newRandom');
  2999. late final _py_newRandom =
  3000. _py_newRandomPtr.asFunction<void Function(py_OutRef)>();
  3001. void py_Random_seed(
  3002. py_Ref self,
  3003. int seed,
  3004. ) {
  3005. return _py_Random_seed(
  3006. self,
  3007. seed,
  3008. );
  3009. }
  3010. late final _py_Random_seedPtr =
  3011. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, py_i64)>>(
  3012. 'py_Random_seed');
  3013. late final _py_Random_seed =
  3014. _py_Random_seedPtr.asFunction<void Function(py_Ref, int)>();
  3015. double py_Random_random(
  3016. py_Ref self,
  3017. ) {
  3018. return _py_Random_random(
  3019. self,
  3020. );
  3021. }
  3022. late final _py_Random_randomPtr =
  3023. _lookup<ffi.NativeFunction<py_f64 Function(py_Ref)>>('py_Random_random');
  3024. late final _py_Random_random =
  3025. _py_Random_randomPtr.asFunction<double Function(py_Ref)>();
  3026. double py_Random_uniform(
  3027. py_Ref self,
  3028. double a,
  3029. double b,
  3030. ) {
  3031. return _py_Random_uniform(
  3032. self,
  3033. a,
  3034. b,
  3035. );
  3036. }
  3037. late final _py_Random_uniformPtr =
  3038. _lookup<ffi.NativeFunction<py_f64 Function(py_Ref, py_f64, py_f64)>>(
  3039. 'py_Random_uniform');
  3040. late final _py_Random_uniform = _py_Random_uniformPtr
  3041. .asFunction<double Function(py_Ref, double, double)>();
  3042. int py_Random_randint(
  3043. py_Ref self,
  3044. int a,
  3045. int b,
  3046. ) {
  3047. return _py_Random_randint(
  3048. self,
  3049. a,
  3050. b,
  3051. );
  3052. }
  3053. late final _py_Random_randintPtr =
  3054. _lookup<ffi.NativeFunction<py_i64 Function(py_Ref, py_i64, py_i64)>>(
  3055. 'py_Random_randint');
  3056. late final _py_Random_randint =
  3057. _py_Random_randintPtr.asFunction<int Function(py_Ref, int, int)>();
  3058. /// array2d module
  3059. void py_newarray2d(
  3060. py_OutRef out,
  3061. int width,
  3062. int height,
  3063. ) {
  3064. return _py_newarray2d(
  3065. out,
  3066. width,
  3067. height,
  3068. );
  3069. }
  3070. late final _py_newarray2dPtr = _lookup<
  3071. ffi.NativeFunction<ffi.Void Function(py_OutRef, ffi.Int, ffi.Int)>>(
  3072. 'py_newarray2d');
  3073. late final _py_newarray2d =
  3074. _py_newarray2dPtr.asFunction<void Function(py_OutRef, int, int)>();
  3075. int py_array2d_getwidth(
  3076. py_Ref self,
  3077. ) {
  3078. return _py_array2d_getwidth(
  3079. self,
  3080. );
  3081. }
  3082. late final _py_array2d_getwidthPtr =
  3083. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref)>>(
  3084. 'py_array2d_getwidth');
  3085. late final _py_array2d_getwidth =
  3086. _py_array2d_getwidthPtr.asFunction<int Function(py_Ref)>();
  3087. int py_array2d_getheight(
  3088. py_Ref self,
  3089. ) {
  3090. return _py_array2d_getheight(
  3091. self,
  3092. );
  3093. }
  3094. late final _py_array2d_getheightPtr =
  3095. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref)>>(
  3096. 'py_array2d_getheight');
  3097. late final _py_array2d_getheight =
  3098. _py_array2d_getheightPtr.asFunction<int Function(py_Ref)>();
  3099. py_ObjectRef py_array2d_getitem(
  3100. py_Ref self,
  3101. int x,
  3102. int y,
  3103. ) {
  3104. return _py_array2d_getitem(
  3105. self,
  3106. x,
  3107. y,
  3108. );
  3109. }
  3110. late final _py_array2d_getitemPtr = _lookup<
  3111. ffi.NativeFunction<py_ObjectRef Function(py_Ref, ffi.Int, ffi.Int)>>(
  3112. 'py_array2d_getitem');
  3113. late final _py_array2d_getitem = _py_array2d_getitemPtr
  3114. .asFunction<py_ObjectRef Function(py_Ref, int, int)>();
  3115. void py_array2d_setitem(
  3116. py_Ref self,
  3117. int x,
  3118. int y,
  3119. py_Ref val,
  3120. ) {
  3121. return _py_array2d_setitem(
  3122. self,
  3123. x,
  3124. y,
  3125. val,
  3126. );
  3127. }
  3128. late final _py_array2d_setitemPtr = _lookup<
  3129. ffi
  3130. .NativeFunction<ffi.Void Function(py_Ref, ffi.Int, ffi.Int, py_Ref)>>(
  3131. 'py_array2d_setitem');
  3132. late final _py_array2d_setitem = _py_array2d_setitemPtr
  3133. .asFunction<void Function(py_Ref, int, int, py_Ref)>();
  3134. /// vmath module
  3135. void py_newvec2(
  3136. py_OutRef out,
  3137. c11_vec2 arg1,
  3138. ) {
  3139. return _py_newvec2(
  3140. out,
  3141. arg1,
  3142. );
  3143. }
  3144. late final _py_newvec2Ptr =
  3145. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, c11_vec2)>>(
  3146. 'py_newvec2');
  3147. late final _py_newvec2 =
  3148. _py_newvec2Ptr.asFunction<void Function(py_OutRef, c11_vec2)>();
  3149. void py_newvec3(
  3150. py_OutRef out,
  3151. c11_vec3 arg1,
  3152. ) {
  3153. return _py_newvec3(
  3154. out,
  3155. arg1,
  3156. );
  3157. }
  3158. late final _py_newvec3Ptr =
  3159. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, c11_vec3)>>(
  3160. 'py_newvec3');
  3161. late final _py_newvec3 =
  3162. _py_newvec3Ptr.asFunction<void Function(py_OutRef, c11_vec3)>();
  3163. void py_newvec2i(
  3164. py_OutRef out,
  3165. c11_vec2i arg1,
  3166. ) {
  3167. return _py_newvec2i(
  3168. out,
  3169. arg1,
  3170. );
  3171. }
  3172. late final _py_newvec2iPtr =
  3173. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, c11_vec2i)>>(
  3174. 'py_newvec2i');
  3175. late final _py_newvec2i =
  3176. _py_newvec2iPtr.asFunction<void Function(py_OutRef, c11_vec2i)>();
  3177. void py_newvec3i(
  3178. py_OutRef out,
  3179. c11_vec3i arg1,
  3180. ) {
  3181. return _py_newvec3i(
  3182. out,
  3183. arg1,
  3184. );
  3185. }
  3186. late final _py_newvec3iPtr =
  3187. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, c11_vec3i)>>(
  3188. 'py_newvec3i');
  3189. late final _py_newvec3i =
  3190. _py_newvec3iPtr.asFunction<void Function(py_OutRef, c11_vec3i)>();
  3191. void py_newvec4i(
  3192. py_OutRef out,
  3193. c11_vec4i arg1,
  3194. ) {
  3195. return _py_newvec4i(
  3196. out,
  3197. arg1,
  3198. );
  3199. }
  3200. late final _py_newvec4iPtr =
  3201. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, c11_vec4i)>>(
  3202. 'py_newvec4i');
  3203. late final _py_newvec4i =
  3204. _py_newvec4iPtr.asFunction<void Function(py_OutRef, c11_vec4i)>();
  3205. void py_newcolor32(
  3206. py_OutRef out,
  3207. c11_color32 arg1,
  3208. ) {
  3209. return _py_newcolor32(
  3210. out,
  3211. arg1,
  3212. );
  3213. }
  3214. late final _py_newcolor32Ptr =
  3215. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, c11_color32)>>(
  3216. 'py_newcolor32');
  3217. late final _py_newcolor32 =
  3218. _py_newcolor32Ptr.asFunction<void Function(py_OutRef, c11_color32)>();
  3219. ffi.Pointer<c11_mat3x3> py_newmat3x3(
  3220. py_OutRef out,
  3221. ) {
  3222. return _py_newmat3x3(
  3223. out,
  3224. );
  3225. }
  3226. late final _py_newmat3x3Ptr =
  3227. _lookup<ffi.NativeFunction<ffi.Pointer<c11_mat3x3> Function(py_OutRef)>>(
  3228. 'py_newmat3x3');
  3229. late final _py_newmat3x3 = _py_newmat3x3Ptr
  3230. .asFunction<ffi.Pointer<c11_mat3x3> Function(py_OutRef)>();
  3231. c11_vec2 py_tovec2(
  3232. py_Ref self,
  3233. ) {
  3234. return _py_tovec2(
  3235. self,
  3236. );
  3237. }
  3238. late final _py_tovec2Ptr =
  3239. _lookup<ffi.NativeFunction<c11_vec2 Function(py_Ref)>>('py_tovec2');
  3240. late final _py_tovec2 = _py_tovec2Ptr.asFunction<c11_vec2 Function(py_Ref)>();
  3241. c11_vec3 py_tovec3(
  3242. py_Ref self,
  3243. ) {
  3244. return _py_tovec3(
  3245. self,
  3246. );
  3247. }
  3248. late final _py_tovec3Ptr =
  3249. _lookup<ffi.NativeFunction<c11_vec3 Function(py_Ref)>>('py_tovec3');
  3250. late final _py_tovec3 = _py_tovec3Ptr.asFunction<c11_vec3 Function(py_Ref)>();
  3251. c11_vec2i py_tovec2i(
  3252. py_Ref self,
  3253. ) {
  3254. return _py_tovec2i(
  3255. self,
  3256. );
  3257. }
  3258. late final _py_tovec2iPtr =
  3259. _lookup<ffi.NativeFunction<c11_vec2i Function(py_Ref)>>('py_tovec2i');
  3260. late final _py_tovec2i =
  3261. _py_tovec2iPtr.asFunction<c11_vec2i Function(py_Ref)>();
  3262. c11_vec3i py_tovec3i(
  3263. py_Ref self,
  3264. ) {
  3265. return _py_tovec3i(
  3266. self,
  3267. );
  3268. }
  3269. late final _py_tovec3iPtr =
  3270. _lookup<ffi.NativeFunction<c11_vec3i Function(py_Ref)>>('py_tovec3i');
  3271. late final _py_tovec3i =
  3272. _py_tovec3iPtr.asFunction<c11_vec3i Function(py_Ref)>();
  3273. c11_vec4i py_tovec4i(
  3274. py_Ref self,
  3275. ) {
  3276. return _py_tovec4i(
  3277. self,
  3278. );
  3279. }
  3280. late final _py_tovec4iPtr =
  3281. _lookup<ffi.NativeFunction<c11_vec4i Function(py_Ref)>>('py_tovec4i');
  3282. late final _py_tovec4i =
  3283. _py_tovec4iPtr.asFunction<c11_vec4i Function(py_Ref)>();
  3284. ffi.Pointer<c11_mat3x3> py_tomat3x3(
  3285. py_Ref self,
  3286. ) {
  3287. return _py_tomat3x3(
  3288. self,
  3289. );
  3290. }
  3291. late final _py_tomat3x3Ptr =
  3292. _lookup<ffi.NativeFunction<ffi.Pointer<c11_mat3x3> Function(py_Ref)>>(
  3293. 'py_tomat3x3');
  3294. late final _py_tomat3x3 =
  3295. _py_tomat3x3Ptr.asFunction<ffi.Pointer<c11_mat3x3> Function(py_Ref)>();
  3296. c11_color32 py_tocolor32(
  3297. py_Ref self,
  3298. ) {
  3299. return _py_tocolor32(
  3300. self,
  3301. );
  3302. }
  3303. late final _py_tocolor32Ptr =
  3304. _lookup<ffi.NativeFunction<c11_color32 Function(py_Ref)>>('py_tocolor32');
  3305. late final _py_tocolor32 =
  3306. _py_tocolor32Ptr.asFunction<c11_color32 Function(py_Ref)>();
  3307. /// json module *************/
  3308. /// /// Python equivalent to `json.dumps(val)`.
  3309. bool py_json_dumps(
  3310. py_Ref val,
  3311. int indent,
  3312. ) {
  3313. return _py_json_dumps(
  3314. val,
  3315. indent,
  3316. );
  3317. }
  3318. late final _py_json_dumpsPtr =
  3319. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, ffi.Int)>>(
  3320. 'py_json_dumps');
  3321. late final _py_json_dumps =
  3322. _py_json_dumpsPtr.asFunction<bool Function(py_Ref, int)>();
  3323. /// Python equivalent to `json.loads(val)`.
  3324. bool py_json_loads(
  3325. ffi.Pointer<ffi.Char> source,
  3326. ) {
  3327. return _py_json_loads(
  3328. source,
  3329. );
  3330. }
  3331. late final _py_json_loadsPtr =
  3332. _lookup<ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Char>)>>(
  3333. 'py_json_loads');
  3334. late final _py_json_loads =
  3335. _py_json_loadsPtr.asFunction<bool Function(ffi.Pointer<ffi.Char>)>();
  3336. /// pickle module *************/
  3337. /// /// Python equivalent to `pickle.dumps(val)`.
  3338. bool py_pickle_dumps(
  3339. py_Ref val,
  3340. ) {
  3341. return _py_pickle_dumps(
  3342. val,
  3343. );
  3344. }
  3345. late final _py_pickle_dumpsPtr =
  3346. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_pickle_dumps');
  3347. late final _py_pickle_dumps =
  3348. _py_pickle_dumpsPtr.asFunction<bool Function(py_Ref)>();
  3349. /// Python equivalent to `pickle.loads(val)`.
  3350. bool py_pickle_loads(
  3351. ffi.Pointer<ffi.UnsignedChar> data,
  3352. int size,
  3353. ) {
  3354. return _py_pickle_loads(
  3355. data,
  3356. size,
  3357. );
  3358. }
  3359. late final _py_pickle_loadsPtr = _lookup<
  3360. ffi.NativeFunction<
  3361. ffi.Bool Function(
  3362. ffi.Pointer<ffi.UnsignedChar>, ffi.Int)>>('py_pickle_loads');
  3363. late final _py_pickle_loads = _py_pickle_loadsPtr
  3364. .asFunction<bool Function(ffi.Pointer<ffi.UnsignedChar>, int)>();
  3365. /// pkpy module *************/
  3366. /// /// Begin the watchdog with `timeout` in milliseconds.
  3367. /// /// `PK_ENABLE_WATCHDOG` must be defined to `1` to use this feature.
  3368. /// /// You need to call `py_watchdog_end()` later.
  3369. /// /// If `timeout` is reached, `TimeoutError` will be raised.
  3370. void py_watchdog_begin(
  3371. int timeout,
  3372. ) {
  3373. return _py_watchdog_begin(
  3374. timeout,
  3375. );
  3376. }
  3377. late final _py_watchdog_beginPtr =
  3378. _lookup<ffi.NativeFunction<ffi.Void Function(py_i64)>>(
  3379. 'py_watchdog_begin');
  3380. late final _py_watchdog_begin =
  3381. _py_watchdog_beginPtr.asFunction<void Function(int)>();
  3382. /// Reset the watchdog.
  3383. void py_watchdog_end() {
  3384. return _py_watchdog_end();
  3385. }
  3386. late final _py_watchdog_endPtr =
  3387. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_watchdog_end');
  3388. late final _py_watchdog_end =
  3389. _py_watchdog_endPtr.asFunction<void Function()>();
  3390. void py_profiler_begin() {
  3391. return _py_profiler_begin();
  3392. }
  3393. late final _py_profiler_beginPtr =
  3394. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_profiler_begin');
  3395. late final _py_profiler_begin =
  3396. _py_profiler_beginPtr.asFunction<void Function()>();
  3397. void py_profiler_end() {
  3398. return _py_profiler_end();
  3399. }
  3400. late final _py_profiler_endPtr =
  3401. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_profiler_end');
  3402. late final _py_profiler_end =
  3403. _py_profiler_endPtr.asFunction<void Function()>();
  3404. void py_profiler_reset() {
  3405. return _py_profiler_reset();
  3406. }
  3407. late final _py_profiler_resetPtr =
  3408. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_profiler_reset');
  3409. late final _py_profiler_reset =
  3410. _py_profiler_resetPtr.asFunction<void Function()>();
  3411. ffi.Pointer<ffi.Char> py_profiler_report() {
  3412. return _py_profiler_report();
  3413. }
  3414. late final _py_profiler_reportPtr =
  3415. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
  3416. 'py_profiler_report');
  3417. late final _py_profiler_report =
  3418. _py_profiler_reportPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
  3419. /// Others
  3420. int time_ns() {
  3421. return _time_ns();
  3422. }
  3423. late final _time_nsPtr =
  3424. _lookup<ffi.NativeFunction<ffi.Int64 Function()>>('time_ns');
  3425. late final _time_ns = _time_nsPtr.asFunction<int Function()>();
  3426. int time_monotonic_ns() {
  3427. return _time_monotonic_ns();
  3428. }
  3429. late final _time_monotonic_nsPtr =
  3430. _lookup<ffi.NativeFunction<ffi.Int64 Function()>>('time_monotonic_ns');
  3431. late final _time_monotonic_ns =
  3432. _time_monotonic_nsPtr.asFunction<int Function()>();
  3433. /// An utility function to read a line from stdin for REPL.
  3434. int py_replinput(
  3435. ffi.Pointer<ffi.Char> buf,
  3436. int max_size,
  3437. ) {
  3438. return _py_replinput(
  3439. buf,
  3440. max_size,
  3441. );
  3442. }
  3443. late final _py_replinputPtr = _lookup<
  3444. ffi.NativeFunction<ffi.Int Function(ffi.Pointer<ffi.Char>, ffi.Int)>>(
  3445. 'py_replinput');
  3446. late final _py_replinput =
  3447. _py_replinputPtr.asFunction<int Function(ffi.Pointer<ffi.Char>, int)>();
  3448. }
  3449. final class py_OpaqueName extends ffi.Opaque {}
  3450. final class py_TValue extends ffi.Struct {
  3451. @py_Type()
  3452. external int type;
  3453. @ffi.Bool()
  3454. external bool is_ptr;
  3455. @ffi.Int()
  3456. external int extra;
  3457. external UnnamedUnion1 unnamed;
  3458. }
  3459. /// An integer that represents a python type. `0` is invalid.
  3460. typedef py_Type = ffi.Int16;
  3461. final class UnnamedUnion1 extends ffi.Union {
  3462. @ffi.Int64()
  3463. external int _i64;
  3464. @ffi.Double()
  3465. external double _f64;
  3466. @ffi.Bool()
  3467. external bool _bool;
  3468. external py_CFunction _cfunc;
  3469. external ffi.Pointer<ffi.Void> _obj;
  3470. external ffi.Pointer<ffi.Void> _ptr;
  3471. @ffi.Array.multi([16])
  3472. external ffi.Array<ffi.Char> _chars;
  3473. }
  3474. /// Native function signature.
  3475. /// @param argc number of arguments.
  3476. /// @param argv array of arguments. Use `py_arg(i)` macro to get the i-th argument.
  3477. /// @return `true` if the function is successful or `false` if an exception is raised.
  3478. typedef py_CFunction = ffi.Pointer<
  3479. ffi.NativeFunction<ffi.Bool Function(ffi.Int argc, py_StackRef argv)>>;
  3480. /// A specific location in the value stack of the VM.
  3481. typedef py_StackRef = ffi.Pointer<py_TValue>;
  3482. /// A string view type. It is helpful for passing strings which are not null-terminated.
  3483. final class c11_sv extends ffi.Struct {
  3484. external ffi.Pointer<ffi.Char> data;
  3485. @ffi.Int()
  3486. external int size;
  3487. }
  3488. final class py_Frame extends ffi.Opaque {}
  3489. /// An enum for tracing events.
  3490. abstract class py_TraceEvent {
  3491. static const int TRACE_EVENT_LINE = 0;
  3492. static const int TRACE_EVENT_PUSH = 1;
  3493. static const int TRACE_EVENT_POP = 2;
  3494. }
  3495. /// A struct contains the callbacks of the VM.
  3496. final class py_Callbacks extends ffi.Struct {
  3497. /// Used by `__import__` to load a source or compiled module.
  3498. external ffi.Pointer<
  3499. ffi.NativeFunction<
  3500. ffi.Pointer<ffi.Char> Function(
  3501. ffi.Pointer<ffi.Char> path, ffi.Pointer<ffi.Int> data_size)>>
  3502. importfile;
  3503. /// Called before `importfile` to lazy-import a C module.
  3504. external ffi
  3505. .Pointer<ffi.NativeFunction<py_GlobalRef Function(ffi.Pointer<ffi.Char>)>>
  3506. lazyimport;
  3507. /// Used by `print` to output a string.
  3508. external ffi
  3509. .Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Char>)>>
  3510. print;
  3511. /// Flush the output buffer of `print`.
  3512. external ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> flush;
  3513. /// Used by `input` to get a character.
  3514. external ffi.Pointer<ffi.NativeFunction<ffi.Int Function()>> getchr;
  3515. /// Used by `gc.collect()` to mark extra objects for garbage collection.
  3516. external ffi.Pointer<
  3517. ffi.NativeFunction<
  3518. ffi.Void Function(
  3519. ffi.Pointer<
  3520. ffi.NativeFunction<
  3521. ffi.Void Function(
  3522. py_Ref val, ffi.Pointer<ffi.Void> ctx)>>
  3523. f,
  3524. ffi.Pointer<ffi.Void> ctx)>> gc_mark;
  3525. /// Used by `PRINT_EXPR` bytecode.
  3526. external ffi.Pointer<ffi.NativeFunction<ffi.Bool Function(py_Ref val)>>
  3527. displayhook;
  3528. }
  3529. /// A global reference which has the same lifespan as the VM.
  3530. typedef py_GlobalRef = ffi.Pointer<py_TValue>;
  3531. /// A generic reference to a python object.
  3532. typedef py_Ref = ffi.Pointer<py_TValue>;
  3533. /// A struct contains the application-level callbacks.
  3534. final class py_AppCallbacks extends ffi.Struct {
  3535. external ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Int index)>>
  3536. on_vm_ctor;
  3537. external ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Int index)>>
  3538. on_vm_dtor;
  3539. }
  3540. /// Python compiler modes.
  3541. /// + `EXEC_MODE`: for statements.
  3542. /// + `EVAL_MODE`: for expressions.
  3543. /// + `SINGLE_MODE`: for REPL or jupyter notebook execution.
  3544. /// + `RELOAD_MODE`: for reloading a module without allocating new types if possible.
  3545. abstract class py_CompileMode {
  3546. static const int EXEC_MODE = 0;
  3547. static const int EVAL_MODE = 1;
  3548. static const int SINGLE_MODE = 2;
  3549. static const int RELOAD_MODE = 3;
  3550. }
  3551. typedef py_TraceFunc = ffi.Pointer<
  3552. ffi.NativeFunction<ffi.Void Function(ffi.Pointer<py_Frame>, ffi.Int32)>>;
  3553. /// An output reference for returning a value. Only use this for function arguments.
  3554. typedef py_OutRef = ffi.Pointer<py_TValue>;
  3555. /// A 64-bit integer type. Corresponds to `int` in python.
  3556. typedef py_i64 = ffi.Int64;
  3557. /// A 64-bit floating-point type. Corresponds to `float` in python.
  3558. typedef py_f64 = ffi.Double;
  3559. /// A pointer that represents a python identifier. For fast name resolution.
  3560. typedef py_Name = ffi.Pointer<py_OpaqueName>;
  3561. /// A generic destructor function.
  3562. typedef py_Dtor
  3563. = ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>;
  3564. /// An item reference to a container object. It invalidates when the container is modified.
  3565. typedef py_ItemRef = ffi.Pointer<py_TValue>;
  3566. /// A reference which has the same lifespan as the python object.
  3567. typedef py_ObjectRef = ffi.Pointer<py_TValue>;
  3568. final class c11_vec2 extends ffi.Union {
  3569. external UnnamedStruct1 unnamed;
  3570. @ffi.Array.multi([2])
  3571. external ffi.Array<ffi.Float> data;
  3572. }
  3573. final class UnnamedStruct1 extends ffi.Struct {
  3574. @ffi.Float()
  3575. external double x;
  3576. @ffi.Float()
  3577. external double y;
  3578. }
  3579. final class c11_vec3 extends ffi.Union {
  3580. external UnnamedStruct2 unnamed;
  3581. @ffi.Array.multi([3])
  3582. external ffi.Array<ffi.Float> data;
  3583. }
  3584. final class UnnamedStruct2 extends ffi.Struct {
  3585. @ffi.Float()
  3586. external double x;
  3587. @ffi.Float()
  3588. external double y;
  3589. @ffi.Float()
  3590. external double z;
  3591. }
  3592. final class c11_vec2i extends ffi.Union {
  3593. external UnnamedStruct3 unnamed;
  3594. @ffi.Array.multi([2])
  3595. external ffi.Array<ffi.Int> data;
  3596. @ffi.Int64()
  3597. external int _i64;
  3598. }
  3599. final class UnnamedStruct3 extends ffi.Struct {
  3600. @ffi.Int()
  3601. external int x;
  3602. @ffi.Int()
  3603. external int y;
  3604. }
  3605. final class c11_vec3i extends ffi.Union {
  3606. external UnnamedStruct4 unnamed;
  3607. @ffi.Array.multi([3])
  3608. external ffi.Array<ffi.Int> data;
  3609. }
  3610. final class UnnamedStruct4 extends ffi.Struct {
  3611. @ffi.Int()
  3612. external int x;
  3613. @ffi.Int()
  3614. external int y;
  3615. @ffi.Int()
  3616. external int z;
  3617. }
  3618. final class c11_vec4i extends ffi.Union {
  3619. external UnnamedStruct5 unnamed;
  3620. @ffi.Array.multi([4])
  3621. external ffi.Array<ffi.Int> data;
  3622. }
  3623. final class UnnamedStruct5 extends ffi.Struct {
  3624. @ffi.Int()
  3625. external int x;
  3626. @ffi.Int()
  3627. external int y;
  3628. @ffi.Int()
  3629. external int z;
  3630. @ffi.Int()
  3631. external int w;
  3632. }
  3633. final class c11_color32 extends ffi.Union {
  3634. external UnnamedStruct6 unnamed;
  3635. @ffi.Array.multi([4])
  3636. external ffi.Array<ffi.UnsignedChar> data;
  3637. @ffi.Uint32()
  3638. external int u32;
  3639. }
  3640. final class UnnamedStruct6 extends ffi.Struct {
  3641. @ffi.UnsignedChar()
  3642. external int r;
  3643. @ffi.UnsignedChar()
  3644. external int g;
  3645. @ffi.UnsignedChar()
  3646. external int b;
  3647. @ffi.UnsignedChar()
  3648. external int a;
  3649. }
  3650. final class c11_mat3x3 extends ffi.Union {
  3651. external UnnamedStruct7 unnamed;
  3652. @ffi.Array.multi([3, 3])
  3653. external ffi.Array<ffi.Array<ffi.Float>> m;
  3654. @ffi.Array.multi([9])
  3655. external ffi.Array<ffi.Float> data;
  3656. }
  3657. final class UnnamedStruct7 extends ffi.Struct {
  3658. @ffi.Float()
  3659. external double _11;
  3660. @ffi.Float()
  3661. external double _12;
  3662. @ffi.Float()
  3663. external double _13;
  3664. @ffi.Float()
  3665. external double _21;
  3666. @ffi.Float()
  3667. external double _22;
  3668. @ffi.Float()
  3669. external double _23;
  3670. @ffi.Float()
  3671. external double _31;
  3672. @ffi.Float()
  3673. external double _32;
  3674. @ffi.Float()
  3675. external double _33;
  3676. }
  3677. /// Python favored string formatting.
  3678. /// %d: int
  3679. /// %i: py_i64 (int64_t)
  3680. /// %f: py_f64 (double)
  3681. /// %s: const char*
  3682. /// %q: c11_sv
  3683. /// %v: c11_sv
  3684. /// %c: char
  3685. /// %p: void*
  3686. /// %t: py_Type
  3687. /// %n: py_Name
  3688. abstract class py_PredefinedType {
  3689. static const int tp_nil = 0;
  3690. static const int tp_object = 1;
  3691. /// py_Type
  3692. static const int tp_type = 2;
  3693. static const int tp_int = 3;
  3694. static const int tp_float = 4;
  3695. static const int tp_bool = 5;
  3696. static const int tp_str = 6;
  3697. static const int tp_str_iterator = 7;
  3698. /// c11_vector
  3699. static const int tp_list = 8;
  3700. /// N slots
  3701. static const int tp_tuple = 9;
  3702. /// 1 slot
  3703. static const int tp_list_iterator = 10;
  3704. /// 1 slot
  3705. static const int tp_tuple_iterator = 11;
  3706. /// 3 slots (start, stop, step)
  3707. static const int tp_slice = 12;
  3708. static const int tp_range = 13;
  3709. static const int tp_range_iterator = 14;
  3710. static const int tp_module = 15;
  3711. static const int tp_function = 16;
  3712. static const int tp_nativefunc = 17;
  3713. /// 2 slots (self, func)
  3714. static const int tp_boundmethod = 18;
  3715. /// 1 slot + py_Type
  3716. static const int tp_super = 19;
  3717. static const int tp_BaseException = 20;
  3718. static const int tp_Exception = 21;
  3719. static const int tp_bytes = 22;
  3720. static const int tp_namedict = 23;
  3721. static const int tp_locals = 24;
  3722. static const int tp_code = 25;
  3723. static const int tp_dict = 26;
  3724. /// 1 slot
  3725. static const int tp_dict_iterator = 27;
  3726. /// 2 slots (getter + setter)
  3727. static const int tp_property = 28;
  3728. /// 1 slot + int level
  3729. static const int tp_star_wrapper = 29;
  3730. /// 1 slot
  3731. static const int tp_staticmethod = 30;
  3732. /// 1 slot
  3733. static const int tp_classmethod = 31;
  3734. static const int tp_NoneType = 32;
  3735. static const int tp_NotImplementedType = 33;
  3736. static const int tp_ellipsis = 34;
  3737. static const int tp_generator = 35;
  3738. /// builtin exceptions
  3739. static const int tp_SystemExit = 36;
  3740. static const int tp_KeyboardInterrupt = 37;
  3741. static const int tp_StopIteration = 38;
  3742. static const int tp_SyntaxError = 39;
  3743. static const int tp_RecursionError = 40;
  3744. static const int tp_OSError = 41;
  3745. static const int tp_NotImplementedError = 42;
  3746. static const int tp_TypeError = 43;
  3747. static const int tp_IndexError = 44;
  3748. static const int tp_ValueError = 45;
  3749. static const int tp_RuntimeError = 46;
  3750. static const int tp_TimeoutError = 47;
  3751. static const int tp_ZeroDivisionError = 48;
  3752. static const int tp_NameError = 49;
  3753. static const int tp_UnboundLocalError = 50;
  3754. static const int tp_AttributeError = 51;
  3755. static const int tp_ImportError = 52;
  3756. static const int tp_AssertionError = 53;
  3757. static const int tp_KeyError = 54;
  3758. /// stdc
  3759. static const int tp_stdc_Memory = 55;
  3760. static const int tp_stdc_Char = 56;
  3761. static const int tp_stdc_UChar = 57;
  3762. static const int tp_stdc_Short = 58;
  3763. static const int tp_stdc_UShort = 59;
  3764. static const int tp_stdc_Int = 60;
  3765. static const int tp_stdc_UInt = 61;
  3766. static const int tp_stdc_Long = 62;
  3767. static const int tp_stdc_ULong = 63;
  3768. static const int tp_stdc_LongLong = 64;
  3769. static const int tp_stdc_ULongLong = 65;
  3770. static const int tp_stdc_Float = 66;
  3771. static const int tp_stdc_Double = 67;
  3772. static const int tp_stdc_Pointer = 68;
  3773. static const int tp_stdc_Bool = 69;
  3774. /// vmath
  3775. static const int tp_vec2 = 70;
  3776. static const int tp_vec3 = 71;
  3777. static const int tp_vec2i = 72;
  3778. static const int tp_vec3i = 73;
  3779. static const int tp_vec4i = 74;
  3780. static const int tp_mat3x3 = 75;
  3781. static const int tp_color32 = 76;
  3782. /// array2d
  3783. static const int tp_array2d_like = 77;
  3784. static const int tp_array2d_like_iterator = 78;
  3785. static const int tp_array2d = 79;
  3786. static const int tp_array2d_view = 80;
  3787. static const int tp_chunked_array2d = 81;
  3788. }