pocketpy_bindings_generated.dart 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301
  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.
  33. void py_finalize() {
  34. return _py_finalize();
  35. }
  36. late final _py_finalizePtr =
  37. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_finalize');
  38. late final _py_finalize = _py_finalizePtr.asFunction<void Function()>();
  39. /// Get the current VM index.
  40. int py_currentvm() {
  41. return _py_currentvm();
  42. }
  43. late final _py_currentvmPtr =
  44. _lookup<ffi.NativeFunction<ffi.Int Function()>>('py_currentvm');
  45. late final _py_currentvm = _py_currentvmPtr.asFunction<int Function()>();
  46. /// Switch to a VM.
  47. /// @param index index of the VM ranging from 0 to 16 (exclusive). `0` is the default VM.
  48. void py_switchvm(
  49. int index,
  50. ) {
  51. return _py_switchvm(
  52. index,
  53. );
  54. }
  55. late final _py_switchvmPtr =
  56. _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int)>>('py_switchvm');
  57. late final _py_switchvm = _py_switchvmPtr.asFunction<void Function(int)>();
  58. /// Reset the current VM.
  59. void py_resetvm() {
  60. return _py_resetvm();
  61. }
  62. late final _py_resetvmPtr =
  63. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_resetvm');
  64. late final _py_resetvm = _py_resetvmPtr.asFunction<void Function()>();
  65. /// Get the current VM context. This is used for user-defined data.
  66. ffi.Pointer<ffi.Void> py_getvmctx() {
  67. return _py_getvmctx();
  68. }
  69. late final _py_getvmctxPtr =
  70. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Void> Function()>>(
  71. 'py_getvmctx');
  72. late final _py_getvmctx =
  73. _py_getvmctxPtr.asFunction<ffi.Pointer<ffi.Void> Function()>();
  74. /// Set the current VM context. This is used for user-defined data.
  75. void py_setvmctx(
  76. ffi.Pointer<ffi.Void> ctx,
  77. ) {
  78. return _py_setvmctx(
  79. ctx,
  80. );
  81. }
  82. late final _py_setvmctxPtr =
  83. _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>(
  84. 'py_setvmctx');
  85. late final _py_setvmctx =
  86. _py_setvmctxPtr.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
  87. /// Interrupt the current VM and raise a `KeyboardInterrupt` exception.
  88. void py_interrupt() {
  89. return _py_interrupt();
  90. }
  91. late final _py_interruptPtr =
  92. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_interrupt');
  93. late final _py_interrupt = _py_interruptPtr.asFunction<void Function()>();
  94. /// Set `sys.argv`. Used for storing command-line arguments.
  95. void py_sys_setargv(
  96. int argc,
  97. ffi.Pointer<ffi.Pointer<ffi.Char>> argv,
  98. ) {
  99. return _py_sys_setargv(
  100. argc,
  101. argv,
  102. );
  103. }
  104. late final _py_sys_setargvPtr = _lookup<
  105. ffi.NativeFunction<
  106. ffi.Void Function(
  107. ffi.Int, ffi.Pointer<ffi.Pointer<ffi.Char>>)>>('py_sys_setargv');
  108. late final _py_sys_setargv = _py_sys_setargvPtr
  109. .asFunction<void Function(int, ffi.Pointer<ffi.Pointer<ffi.Char>>)>();
  110. /// Setup the callbacks for the current VM.
  111. ffi.Pointer<py_Callbacks> py_callbacks() {
  112. return _py_callbacks();
  113. }
  114. late final _py_callbacksPtr =
  115. _lookup<ffi.NativeFunction<ffi.Pointer<py_Callbacks> Function()>>(
  116. 'py_callbacks');
  117. late final _py_callbacks =
  118. _py_callbacksPtr.asFunction<ffi.Pointer<py_Callbacks> Function()>();
  119. /// Run a source string.
  120. /// @param source source string.
  121. /// @param filename filename (for error messages).
  122. /// @param mode compile mode. Use `EXEC_MODE` for statements `EVAL_MODE` for expressions.
  123. /// @param module target module. Use NULL for the main module.
  124. /// @return `true` if the execution is successful or `false` if an exception is raised.
  125. bool py_exec(
  126. ffi.Pointer<ffi.Char> source,
  127. ffi.Pointer<ffi.Char> filename,
  128. int mode,
  129. py_Ref module,
  130. ) {
  131. return _py_exec(
  132. source,
  133. filename,
  134. mode,
  135. module,
  136. );
  137. }
  138. late final _py_execPtr = _lookup<
  139. ffi.NativeFunction<
  140. ffi.Bool Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>,
  141. ffi.Int32, py_Ref)>>('py_exec');
  142. late final _py_exec = _py_execPtr.asFunction<
  143. bool Function(
  144. ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, int, py_Ref)>();
  145. /// Evaluate a source string. Equivalent to `py_exec(source, "<string>", EVAL_MODE, module)`.
  146. bool py_eval(
  147. ffi.Pointer<ffi.Char> source,
  148. py_Ref module,
  149. ) {
  150. return _py_eval(
  151. source,
  152. module,
  153. );
  154. }
  155. late final _py_evalPtr = _lookup<
  156. ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Char>, py_Ref)>>(
  157. 'py_eval');
  158. late final _py_eval =
  159. _py_evalPtr.asFunction<bool Function(ffi.Pointer<ffi.Char>, py_Ref)>();
  160. /// Run a source string with smart interpretation.
  161. /// Example:
  162. /// `py_newstr(py_r0(), "abc");`
  163. /// `py_newint(py_r1(), 123);`
  164. /// `py_smartexec("print(_0, _1)", NULL, py_r0(), py_r1());`
  165. /// `// "abc 123" will be printed`.
  166. bool py_smartexec(
  167. ffi.Pointer<ffi.Char> source,
  168. py_Ref module,
  169. ) {
  170. return _py_smartexec(
  171. source,
  172. module,
  173. );
  174. }
  175. late final _py_smartexecPtr = _lookup<
  176. ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Char>, py_Ref)>>(
  177. 'py_smartexec');
  178. late final _py_smartexec = _py_smartexecPtr
  179. .asFunction<bool Function(ffi.Pointer<ffi.Char>, py_Ref)>();
  180. /// Evaluate a source string with smart interpretation.
  181. /// Example:
  182. /// `py_newstr(py_r0(), "abc");`
  183. /// `py_smarteval("len(_)", NULL, py_r0());`
  184. /// `int res = py_toint(py_retval());`
  185. /// `// res will be 3`.
  186. bool py_smarteval(
  187. ffi.Pointer<ffi.Char> source,
  188. py_Ref module,
  189. ) {
  190. return _py_smarteval(
  191. source,
  192. module,
  193. );
  194. }
  195. late final _py_smartevalPtr = _lookup<
  196. ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Char>, py_Ref)>>(
  197. 'py_smarteval');
  198. late final _py_smarteval = _py_smartevalPtr
  199. .asFunction<bool Function(ffi.Pointer<ffi.Char>, py_Ref)>();
  200. /// Compile a source string into a code object.
  201. /// Use python's `exec()` or `eval()` to execute it.
  202. bool py_compile(
  203. ffi.Pointer<ffi.Char> source,
  204. ffi.Pointer<ffi.Char> filename,
  205. int mode,
  206. bool is_dynamic,
  207. ) {
  208. return _py_compile(
  209. source,
  210. filename,
  211. mode,
  212. is_dynamic,
  213. );
  214. }
  215. late final _py_compilePtr = _lookup<
  216. ffi.NativeFunction<
  217. ffi.Bool Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>,
  218. ffi.Int32, ffi.Bool)>>('py_compile');
  219. late final _py_compile = _py_compilePtr.asFunction<
  220. bool Function(ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>, int, bool)>();
  221. /// Python equivalent to `globals()`.
  222. void py_newglobals(
  223. py_OutRef arg0,
  224. ) {
  225. return _py_newglobals(
  226. arg0,
  227. );
  228. }
  229. late final _py_newglobalsPtr =
  230. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>(
  231. 'py_newglobals');
  232. late final _py_newglobals =
  233. _py_newglobalsPtr.asFunction<void Function(py_OutRef)>();
  234. /// Python equivalent to `locals()`.
  235. void py_newlocals(
  236. py_OutRef arg0,
  237. ) {
  238. return _py_newlocals(
  239. arg0,
  240. );
  241. }
  242. late final _py_newlocalsPtr =
  243. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>('py_newlocals');
  244. late final _py_newlocals =
  245. _py_newlocalsPtr.asFunction<void Function(py_OutRef)>();
  246. /// A shorthand for `True`.
  247. py_GlobalRef py_True() {
  248. return _py_True();
  249. }
  250. late final _py_TruePtr =
  251. _lookup<ffi.NativeFunction<py_GlobalRef Function()>>('py_True');
  252. late final _py_True = _py_TruePtr.asFunction<py_GlobalRef Function()>();
  253. /// A shorthand for `False`.
  254. py_GlobalRef py_False() {
  255. return _py_False();
  256. }
  257. late final _py_FalsePtr =
  258. _lookup<ffi.NativeFunction<py_GlobalRef Function()>>('py_False');
  259. late final _py_False = _py_FalsePtr.asFunction<py_GlobalRef Function()>();
  260. /// A shorthand for `None`.
  261. py_GlobalRef py_None() {
  262. return _py_None();
  263. }
  264. late final _py_NonePtr =
  265. _lookup<ffi.NativeFunction<py_GlobalRef Function()>>('py_None');
  266. late final _py_None = _py_NonePtr.asFunction<py_GlobalRef Function()>();
  267. /// A shorthand for `nil`. `nil` is not a valid python object.
  268. py_GlobalRef py_NIL() {
  269. return _py_NIL();
  270. }
  271. late final _py_NILPtr =
  272. _lookup<ffi.NativeFunction<py_GlobalRef Function()>>('py_NIL');
  273. late final _py_NIL = _py_NILPtr.asFunction<py_GlobalRef Function()>();
  274. /// Create an `int` object.
  275. void py_newint(
  276. py_OutRef arg0,
  277. int arg1,
  278. ) {
  279. return _py_newint(
  280. arg0,
  281. arg1,
  282. );
  283. }
  284. late final _py_newintPtr =
  285. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, py_i64)>>(
  286. 'py_newint');
  287. late final _py_newint =
  288. _py_newintPtr.asFunction<void Function(py_OutRef, int)>();
  289. /// Create a `float` object.
  290. void py_newfloat(
  291. py_OutRef arg0,
  292. double arg1,
  293. ) {
  294. return _py_newfloat(
  295. arg0,
  296. arg1,
  297. );
  298. }
  299. late final _py_newfloatPtr =
  300. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, py_f64)>>(
  301. 'py_newfloat');
  302. late final _py_newfloat =
  303. _py_newfloatPtr.asFunction<void Function(py_OutRef, double)>();
  304. /// Create a `bool` object.
  305. void py_newbool(
  306. py_OutRef arg0,
  307. bool arg1,
  308. ) {
  309. return _py_newbool(
  310. arg0,
  311. arg1,
  312. );
  313. }
  314. late final _py_newboolPtr =
  315. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, ffi.Bool)>>(
  316. 'py_newbool');
  317. late final _py_newbool =
  318. _py_newboolPtr.asFunction<void Function(py_OutRef, bool)>();
  319. /// Create a `str` object from a null-terminated string (utf-8).
  320. void py_newstr(
  321. py_OutRef arg0,
  322. ffi.Pointer<ffi.Char> arg1,
  323. ) {
  324. return _py_newstr(
  325. arg0,
  326. arg1,
  327. );
  328. }
  329. late final _py_newstrPtr = _lookup<
  330. ffi.NativeFunction<
  331. ffi.Void Function(py_OutRef, ffi.Pointer<ffi.Char>)>>('py_newstr');
  332. late final _py_newstr = _py_newstrPtr
  333. .asFunction<void Function(py_OutRef, ffi.Pointer<ffi.Char>)>();
  334. /// Create a `str` object with `n` UNINITIALIZED bytes plus `'\0'`.
  335. ffi.Pointer<ffi.Char> py_newstrn(
  336. py_OutRef arg0,
  337. int arg1,
  338. ) {
  339. return _py_newstrn(
  340. arg0,
  341. arg1,
  342. );
  343. }
  344. late final _py_newstrnPtr = _lookup<
  345. ffi.NativeFunction<
  346. ffi.Pointer<ffi.Char> Function(py_OutRef, ffi.Int)>>('py_newstrn');
  347. late final _py_newstrn = _py_newstrnPtr
  348. .asFunction<ffi.Pointer<ffi.Char> Function(py_OutRef, int)>();
  349. /// Create a `str` object from a `c11_sv`.
  350. void py_newstrv(
  351. py_OutRef arg0,
  352. c11_sv arg1,
  353. ) {
  354. return _py_newstrv(
  355. arg0,
  356. arg1,
  357. );
  358. }
  359. late final _py_newstrvPtr =
  360. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, c11_sv)>>(
  361. 'py_newstrv');
  362. late final _py_newstrv =
  363. _py_newstrvPtr.asFunction<void Function(py_OutRef, c11_sv)>();
  364. /// Create a formatted `str` object.
  365. void py_newfstr(
  366. py_OutRef arg0,
  367. ffi.Pointer<ffi.Char> arg1,
  368. ) {
  369. return _py_newfstr(
  370. arg0,
  371. arg1,
  372. );
  373. }
  374. late final _py_newfstrPtr = _lookup<
  375. ffi.NativeFunction<
  376. ffi.Void Function(py_OutRef, ffi.Pointer<ffi.Char>)>>('py_newfstr');
  377. late final _py_newfstr = _py_newfstrPtr
  378. .asFunction<void Function(py_OutRef, ffi.Pointer<ffi.Char>)>();
  379. /// Create a `bytes` object with `n` UNINITIALIZED bytes.
  380. ffi.Pointer<ffi.UnsignedChar> py_newbytes(
  381. py_OutRef arg0,
  382. int n,
  383. ) {
  384. return _py_newbytes(
  385. arg0,
  386. n,
  387. );
  388. }
  389. late final _py_newbytesPtr = _lookup<
  390. ffi.NativeFunction<
  391. ffi.Pointer<ffi.UnsignedChar> Function(
  392. py_OutRef, ffi.Int)>>('py_newbytes');
  393. late final _py_newbytes = _py_newbytesPtr
  394. .asFunction<ffi.Pointer<ffi.UnsignedChar> Function(py_OutRef, int)>();
  395. /// Create a `None` object.
  396. void py_newnone(
  397. py_OutRef arg0,
  398. ) {
  399. return _py_newnone(
  400. arg0,
  401. );
  402. }
  403. late final _py_newnonePtr =
  404. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>('py_newnone');
  405. late final _py_newnone =
  406. _py_newnonePtr.asFunction<void Function(py_OutRef)>();
  407. /// Create a `NotImplemented` object.
  408. void py_newnotimplemented(
  409. py_OutRef arg0,
  410. ) {
  411. return _py_newnotimplemented(
  412. arg0,
  413. );
  414. }
  415. late final _py_newnotimplementedPtr =
  416. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>(
  417. 'py_newnotimplemented');
  418. late final _py_newnotimplemented =
  419. _py_newnotimplementedPtr.asFunction<void Function(py_OutRef)>();
  420. /// Create a `...` object.
  421. void py_newellipsis(
  422. py_OutRef arg0,
  423. ) {
  424. return _py_newellipsis(
  425. arg0,
  426. );
  427. }
  428. late final _py_newellipsisPtr =
  429. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>(
  430. 'py_newellipsis');
  431. late final _py_newellipsis =
  432. _py_newellipsisPtr.asFunction<void Function(py_OutRef)>();
  433. /// Create a `nil` object. `nil` is an invalid representation of an object.
  434. /// Don't use it unless you know what you are doing.
  435. void py_newnil(
  436. py_OutRef arg0,
  437. ) {
  438. return _py_newnil(
  439. arg0,
  440. );
  441. }
  442. late final _py_newnilPtr =
  443. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>('py_newnil');
  444. late final _py_newnil = _py_newnilPtr.asFunction<void Function(py_OutRef)>();
  445. /// Create a `tuple` with `n` UNINITIALIZED elements.
  446. /// You should initialize all elements before using it.
  447. py_ObjectRef py_newtuple(
  448. py_OutRef arg0,
  449. int n,
  450. ) {
  451. return _py_newtuple(
  452. arg0,
  453. n,
  454. );
  455. }
  456. late final _py_newtuplePtr =
  457. _lookup<ffi.NativeFunction<py_ObjectRef Function(py_OutRef, ffi.Int)>>(
  458. 'py_newtuple');
  459. late final _py_newtuple =
  460. _py_newtuplePtr.asFunction<py_ObjectRef Function(py_OutRef, int)>();
  461. /// Create an empty `list`.
  462. void py_newlist(
  463. py_OutRef arg0,
  464. ) {
  465. return _py_newlist(
  466. arg0,
  467. );
  468. }
  469. late final _py_newlistPtr =
  470. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>('py_newlist');
  471. late final _py_newlist =
  472. _py_newlistPtr.asFunction<void Function(py_OutRef)>();
  473. /// Create a `list` with `n` UNINITIALIZED elements.
  474. /// You should initialize all elements before using it.
  475. void py_newlistn(
  476. py_OutRef arg0,
  477. int n,
  478. ) {
  479. return _py_newlistn(
  480. arg0,
  481. n,
  482. );
  483. }
  484. late final _py_newlistnPtr =
  485. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, ffi.Int)>>(
  486. 'py_newlistn');
  487. late final _py_newlistn =
  488. _py_newlistnPtr.asFunction<void Function(py_OutRef, int)>();
  489. /// Create an empty `dict`.
  490. void py_newdict(
  491. py_OutRef arg0,
  492. ) {
  493. return _py_newdict(
  494. arg0,
  495. );
  496. }
  497. late final _py_newdictPtr =
  498. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>('py_newdict');
  499. late final _py_newdict =
  500. _py_newdictPtr.asFunction<void Function(py_OutRef)>();
  501. /// Create an UNINITIALIZED `slice` object.
  502. /// You should use `py_setslot()` to set `start`, `stop`, and `step`.
  503. void py_newslice(
  504. py_OutRef arg0,
  505. ) {
  506. return _py_newslice(
  507. arg0,
  508. );
  509. }
  510. late final _py_newslicePtr =
  511. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef)>>('py_newslice');
  512. late final _py_newslice =
  513. _py_newslicePtr.asFunction<void Function(py_OutRef)>();
  514. /// Create a `nativefunc` object.
  515. void py_newnativefunc(
  516. py_OutRef arg0,
  517. py_CFunction arg1,
  518. ) {
  519. return _py_newnativefunc(
  520. arg0,
  521. arg1,
  522. );
  523. }
  524. late final _py_newnativefuncPtr =
  525. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, py_CFunction)>>(
  526. 'py_newnativefunc');
  527. late final _py_newnativefunc =
  528. _py_newnativefuncPtr.asFunction<void Function(py_OutRef, py_CFunction)>();
  529. /// Create a `function` object.
  530. int py_newfunction(
  531. py_OutRef out,
  532. ffi.Pointer<ffi.Char> sig,
  533. py_CFunction f,
  534. ffi.Pointer<ffi.Char> docstring,
  535. int slots,
  536. ) {
  537. return _py_newfunction(
  538. out,
  539. sig,
  540. f,
  541. docstring,
  542. slots,
  543. );
  544. }
  545. late final _py_newfunctionPtr = _lookup<
  546. ffi.NativeFunction<
  547. py_Name Function(py_OutRef, ffi.Pointer<ffi.Char>, py_CFunction,
  548. ffi.Pointer<ffi.Char>, ffi.Int)>>('py_newfunction');
  549. late final _py_newfunction = _py_newfunctionPtr.asFunction<
  550. int Function(py_OutRef, ffi.Pointer<ffi.Char>, py_CFunction,
  551. ffi.Pointer<ffi.Char>, int)>();
  552. /// Create a `boundmethod` object.
  553. void py_newboundmethod(
  554. py_OutRef out,
  555. py_Ref self,
  556. py_Ref func,
  557. ) {
  558. return _py_newboundmethod(
  559. out,
  560. self,
  561. func,
  562. );
  563. }
  564. late final _py_newboundmethodPtr =
  565. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, py_Ref, py_Ref)>>(
  566. 'py_newboundmethod');
  567. late final _py_newboundmethod = _py_newboundmethodPtr
  568. .asFunction<void Function(py_OutRef, py_Ref, py_Ref)>();
  569. /// Convert a null-terminated string to a name.
  570. int py_name(
  571. ffi.Pointer<ffi.Char> arg0,
  572. ) {
  573. return _py_name(
  574. arg0,
  575. );
  576. }
  577. late final _py_namePtr =
  578. _lookup<ffi.NativeFunction<py_Name Function(ffi.Pointer<ffi.Char>)>>(
  579. 'py_name');
  580. late final _py_name =
  581. _py_namePtr.asFunction<int Function(ffi.Pointer<ffi.Char>)>();
  582. /// Convert a name to a null-terminated string.
  583. ffi.Pointer<ffi.Char> py_name2str(
  584. int arg0,
  585. ) {
  586. return _py_name2str(
  587. arg0,
  588. );
  589. }
  590. late final _py_name2strPtr =
  591. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function(py_Name)>>(
  592. 'py_name2str');
  593. late final _py_name2str =
  594. _py_name2strPtr.asFunction<ffi.Pointer<ffi.Char> Function(int)>();
  595. /// Convert a name to a python `str` object with cache.
  596. py_GlobalRef py_name2ref(
  597. int arg0,
  598. ) {
  599. return _py_name2ref(
  600. arg0,
  601. );
  602. }
  603. late final _py_name2refPtr =
  604. _lookup<ffi.NativeFunction<py_GlobalRef Function(py_Name)>>(
  605. 'py_name2ref');
  606. late final _py_name2ref =
  607. _py_name2refPtr.asFunction<py_GlobalRef Function(int)>();
  608. /// Convert a `c11_sv` to a name.
  609. int py_namev(
  610. c11_sv arg0,
  611. ) {
  612. return _py_namev(
  613. arg0,
  614. );
  615. }
  616. late final _py_namevPtr =
  617. _lookup<ffi.NativeFunction<py_Name Function(c11_sv)>>('py_namev');
  618. late final _py_namev = _py_namevPtr.asFunction<int Function(c11_sv)>();
  619. /// Convert a name to a `c11_sv`.
  620. c11_sv py_name2sv(
  621. int arg0,
  622. ) {
  623. return _py_name2sv(
  624. arg0,
  625. );
  626. }
  627. late final _py_name2svPtr =
  628. _lookup<ffi.NativeFunction<c11_sv Function(py_Name)>>('py_name2sv');
  629. late final _py_name2sv = _py_name2svPtr.asFunction<c11_sv Function(int)>();
  630. /// Create a new type.
  631. /// @param name name of the type.
  632. /// @param base base type.
  633. /// @param module module where the type is defined. Use `NULL` for built-in types.
  634. /// @param dtor destructor function. Use `NULL` if not needed.
  635. int py_newtype(
  636. ffi.Pointer<ffi.Char> name,
  637. int base,
  638. py_GlobalRef module,
  639. py_Dtor dtor,
  640. ) {
  641. return _py_newtype(
  642. name,
  643. base,
  644. module,
  645. dtor,
  646. );
  647. }
  648. late final _py_newtypePtr = _lookup<
  649. ffi.NativeFunction<
  650. py_Type Function(ffi.Pointer<ffi.Char>, py_Type, py_GlobalRef,
  651. py_Dtor)>>('py_newtype');
  652. late final _py_newtype = _py_newtypePtr.asFunction<
  653. int Function(ffi.Pointer<ffi.Char>, int, py_GlobalRef, py_Dtor)>();
  654. /// Create a new object.
  655. /// @param out output reference.
  656. /// @param type type of the object.
  657. /// @param slots number of slots. Use `-1` to create a `__dict__`.
  658. /// @param udsize size of your userdata.
  659. /// @return pointer to the userdata.
  660. ffi.Pointer<ffi.Void> py_newobject(
  661. py_OutRef out,
  662. int type,
  663. int slots,
  664. int udsize,
  665. ) {
  666. return _py_newobject(
  667. out,
  668. type,
  669. slots,
  670. udsize,
  671. );
  672. }
  673. late final _py_newobjectPtr = _lookup<
  674. ffi.NativeFunction<
  675. ffi.Pointer<ffi.Void> Function(
  676. py_OutRef, py_Type, ffi.Int, ffi.Int)>>('py_newobject');
  677. late final _py_newobject = _py_newobjectPtr
  678. .asFunction<ffi.Pointer<ffi.Void> Function(py_OutRef, int, int, int)>();
  679. /// Convert an `int` object in python to `int64_t`.
  680. int py_toint(
  681. py_Ref arg0,
  682. ) {
  683. return _py_toint(
  684. arg0,
  685. );
  686. }
  687. late final _py_tointPtr =
  688. _lookup<ffi.NativeFunction<py_i64 Function(py_Ref)>>('py_toint');
  689. late final _py_toint = _py_tointPtr.asFunction<int Function(py_Ref)>();
  690. /// Convert a `float` object in python to `double`.
  691. double py_tofloat(
  692. py_Ref arg0,
  693. ) {
  694. return _py_tofloat(
  695. arg0,
  696. );
  697. }
  698. late final _py_tofloatPtr =
  699. _lookup<ffi.NativeFunction<py_f64 Function(py_Ref)>>('py_tofloat');
  700. late final _py_tofloat = _py_tofloatPtr.asFunction<double Function(py_Ref)>();
  701. /// Cast a `int` or `float` object in python to `double`.
  702. /// If successful, return true and set the value to `out`.
  703. /// Otherwise, return false and raise `TypeError`.
  704. bool py_castfloat(
  705. py_Ref arg0,
  706. ffi.Pointer<py_f64> out,
  707. ) {
  708. return _py_castfloat(
  709. arg0,
  710. out,
  711. );
  712. }
  713. late final _py_castfloatPtr = _lookup<
  714. ffi.NativeFunction<ffi.Bool Function(py_Ref, ffi.Pointer<py_f64>)>>(
  715. 'py_castfloat');
  716. late final _py_castfloat =
  717. _py_castfloatPtr.asFunction<bool Function(py_Ref, ffi.Pointer<py_f64>)>();
  718. /// 32-bit version of `py_castfloat`.
  719. bool py_castfloat32(
  720. py_Ref arg0,
  721. ffi.Pointer<ffi.Float> out,
  722. ) {
  723. return _py_castfloat32(
  724. arg0,
  725. out,
  726. );
  727. }
  728. late final _py_castfloat32Ptr = _lookup<
  729. ffi.NativeFunction<
  730. ffi.Bool Function(py_Ref, ffi.Pointer<ffi.Float>)>>('py_castfloat32');
  731. late final _py_castfloat32 = _py_castfloat32Ptr
  732. .asFunction<bool Function(py_Ref, ffi.Pointer<ffi.Float>)>();
  733. /// Cast a `int` object in python to `int64_t`.
  734. bool py_castint(
  735. py_Ref arg0,
  736. ffi.Pointer<py_i64> out,
  737. ) {
  738. return _py_castint(
  739. arg0,
  740. out,
  741. );
  742. }
  743. late final _py_castintPtr = _lookup<
  744. ffi.NativeFunction<ffi.Bool Function(py_Ref, ffi.Pointer<py_i64>)>>(
  745. 'py_castint');
  746. late final _py_castint =
  747. _py_castintPtr.asFunction<bool Function(py_Ref, ffi.Pointer<py_i64>)>();
  748. /// Convert a `bool` object in python to `bool`.
  749. bool py_tobool(
  750. py_Ref arg0,
  751. ) {
  752. return _py_tobool(
  753. arg0,
  754. );
  755. }
  756. late final _py_toboolPtr =
  757. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_tobool');
  758. late final _py_tobool = _py_toboolPtr.asFunction<bool Function(py_Ref)>();
  759. /// Convert a `type` object in python to `py_Type`.
  760. int py_totype(
  761. py_Ref arg0,
  762. ) {
  763. return _py_totype(
  764. arg0,
  765. );
  766. }
  767. late final _py_totypePtr =
  768. _lookup<ffi.NativeFunction<py_Type Function(py_Ref)>>('py_totype');
  769. late final _py_totype = _py_totypePtr.asFunction<int Function(py_Ref)>();
  770. /// Convert a `str` object in python to null-terminated string.
  771. ffi.Pointer<ffi.Char> py_tostr(
  772. py_Ref arg0,
  773. ) {
  774. return _py_tostr(
  775. arg0,
  776. );
  777. }
  778. late final _py_tostrPtr =
  779. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function(py_Ref)>>(
  780. 'py_tostr');
  781. late final _py_tostr =
  782. _py_tostrPtr.asFunction<ffi.Pointer<ffi.Char> Function(py_Ref)>();
  783. /// Convert a `str` object in python to char array.
  784. ffi.Pointer<ffi.Char> py_tostrn(
  785. py_Ref arg0,
  786. ffi.Pointer<ffi.Int> size,
  787. ) {
  788. return _py_tostrn(
  789. arg0,
  790. size,
  791. );
  792. }
  793. late final _py_tostrnPtr = _lookup<
  794. ffi.NativeFunction<
  795. ffi.Pointer<ffi.Char> Function(
  796. py_Ref, ffi.Pointer<ffi.Int>)>>('py_tostrn');
  797. late final _py_tostrn = _py_tostrnPtr.asFunction<
  798. ffi.Pointer<ffi.Char> Function(py_Ref, ffi.Pointer<ffi.Int>)>();
  799. /// Convert a `str` object in python to `c11_sv`.
  800. c11_sv py_tosv(
  801. py_Ref arg0,
  802. ) {
  803. return _py_tosv(
  804. arg0,
  805. );
  806. }
  807. late final _py_tosvPtr =
  808. _lookup<ffi.NativeFunction<c11_sv Function(py_Ref)>>('py_tosv');
  809. late final _py_tosv = _py_tosvPtr.asFunction<c11_sv Function(py_Ref)>();
  810. /// Convert a `bytes` object in python to char array.
  811. ffi.Pointer<ffi.UnsignedChar> py_tobytes(
  812. py_Ref arg0,
  813. ffi.Pointer<ffi.Int> size,
  814. ) {
  815. return _py_tobytes(
  816. arg0,
  817. size,
  818. );
  819. }
  820. late final _py_tobytesPtr = _lookup<
  821. ffi.NativeFunction<
  822. ffi.Pointer<ffi.UnsignedChar> Function(
  823. py_Ref, ffi.Pointer<ffi.Int>)>>('py_tobytes');
  824. late final _py_tobytes = _py_tobytesPtr.asFunction<
  825. ffi.Pointer<ffi.UnsignedChar> Function(py_Ref, ffi.Pointer<ffi.Int>)>();
  826. /// Resize a `bytes` object. It can only be resized down.
  827. void py_bytes_resize(
  828. py_Ref arg0,
  829. int size,
  830. ) {
  831. return _py_bytes_resize(
  832. arg0,
  833. size,
  834. );
  835. }
  836. late final _py_bytes_resizePtr =
  837. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int)>>(
  838. 'py_bytes_resize');
  839. late final _py_bytes_resize =
  840. _py_bytes_resizePtr.asFunction<void Function(py_Ref, int)>();
  841. /// Convert a user-defined object to its userdata.
  842. ffi.Pointer<ffi.Void> py_touserdata(
  843. py_Ref arg0,
  844. ) {
  845. return _py_touserdata(
  846. arg0,
  847. );
  848. }
  849. late final _py_touserdataPtr =
  850. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Void> Function(py_Ref)>>(
  851. 'py_touserdata');
  852. late final _py_touserdata =
  853. _py_touserdataPtr.asFunction<ffi.Pointer<ffi.Void> Function(py_Ref)>();
  854. /// Get the type of the object.
  855. int py_typeof(
  856. py_Ref self,
  857. ) {
  858. return _py_typeof(
  859. self,
  860. );
  861. }
  862. late final _py_typeofPtr =
  863. _lookup<ffi.NativeFunction<py_Type Function(py_Ref)>>('py_typeof');
  864. late final _py_typeof = _py_typeofPtr.asFunction<int Function(py_Ref)>();
  865. /// Get type by module and name. e.g. `py_gettype("time", py_name("struct_time"))`.
  866. /// Return `0` if not found.
  867. int py_gettype(
  868. ffi.Pointer<ffi.Char> module,
  869. int name,
  870. ) {
  871. return _py_gettype(
  872. module,
  873. name,
  874. );
  875. }
  876. late final _py_gettypePtr = _lookup<
  877. ffi.NativeFunction<py_Type Function(ffi.Pointer<ffi.Char>, py_Name)>>(
  878. 'py_gettype');
  879. late final _py_gettype =
  880. _py_gettypePtr.asFunction<int Function(ffi.Pointer<ffi.Char>, int)>();
  881. /// Check if the object is exactly the given type.
  882. bool py_istype(
  883. py_Ref arg0,
  884. int arg1,
  885. ) {
  886. return _py_istype(
  887. arg0,
  888. arg1,
  889. );
  890. }
  891. late final _py_istypePtr =
  892. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Type)>>(
  893. 'py_istype');
  894. late final _py_istype =
  895. _py_istypePtr.asFunction<bool Function(py_Ref, int)>();
  896. /// Check if the object is an instance of the given type.
  897. bool py_isinstance(
  898. py_Ref obj,
  899. int type,
  900. ) {
  901. return _py_isinstance(
  902. obj,
  903. type,
  904. );
  905. }
  906. late final _py_isinstancePtr =
  907. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Type)>>(
  908. 'py_isinstance');
  909. late final _py_isinstance =
  910. _py_isinstancePtr.asFunction<bool Function(py_Ref, int)>();
  911. /// Check if the derived type is a subclass of the base type.
  912. bool py_issubclass(
  913. int derived,
  914. int base,
  915. ) {
  916. return _py_issubclass(
  917. derived,
  918. base,
  919. );
  920. }
  921. late final _py_issubclassPtr =
  922. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Type, py_Type)>>(
  923. 'py_issubclass');
  924. late final _py_issubclass =
  925. _py_issubclassPtr.asFunction<bool Function(int, int)>();
  926. /// Get the magic method from the given type only.
  927. /// The returned reference is always valid. However, its value may be `nil`.
  928. py_GlobalRef py_tpgetmagic(
  929. int type,
  930. int name,
  931. ) {
  932. return _py_tpgetmagic(
  933. type,
  934. name,
  935. );
  936. }
  937. late final _py_tpgetmagicPtr =
  938. _lookup<ffi.NativeFunction<py_GlobalRef Function(py_Type, py_Name)>>(
  939. 'py_tpgetmagic');
  940. late final _py_tpgetmagic =
  941. _py_tpgetmagicPtr.asFunction<py_GlobalRef Function(int, int)>();
  942. /// Search the magic method from the given type to the base type.
  943. /// Return `NULL` if not found.
  944. py_GlobalRef py_tpfindmagic(
  945. int arg0,
  946. int name,
  947. ) {
  948. return _py_tpfindmagic(
  949. arg0,
  950. name,
  951. );
  952. }
  953. late final _py_tpfindmagicPtr =
  954. _lookup<ffi.NativeFunction<py_GlobalRef Function(py_Type, py_Name)>>(
  955. 'py_tpfindmagic');
  956. late final _py_tpfindmagic =
  957. _py_tpfindmagicPtr.asFunction<py_GlobalRef Function(int, int)>();
  958. /// Search the name from the given type to the base type.
  959. /// Return `NULL` if not found.
  960. py_ItemRef py_tpfindname(
  961. int arg0,
  962. int name,
  963. ) {
  964. return _py_tpfindname(
  965. arg0,
  966. name,
  967. );
  968. }
  969. late final _py_tpfindnamePtr =
  970. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Type, py_Name)>>(
  971. 'py_tpfindname');
  972. late final _py_tpfindname =
  973. _py_tpfindnamePtr.asFunction<py_ItemRef Function(int, int)>();
  974. /// Get the type object of the given type.
  975. py_GlobalRef py_tpobject(
  976. int type,
  977. ) {
  978. return _py_tpobject(
  979. type,
  980. );
  981. }
  982. late final _py_tpobjectPtr =
  983. _lookup<ffi.NativeFunction<py_GlobalRef Function(py_Type)>>(
  984. 'py_tpobject');
  985. late final _py_tpobject =
  986. _py_tpobjectPtr.asFunction<py_GlobalRef Function(int)>();
  987. /// Get the type name.
  988. ffi.Pointer<ffi.Char> py_tpname(
  989. int type,
  990. ) {
  991. return _py_tpname(
  992. type,
  993. );
  994. }
  995. late final _py_tpnamePtr =
  996. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function(py_Type)>>(
  997. 'py_tpname');
  998. late final _py_tpname =
  999. _py_tpnamePtr.asFunction<ffi.Pointer<ffi.Char> Function(int)>();
  1000. /// Call a type to create a new instance.
  1001. bool py_tpcall(
  1002. int type,
  1003. int argc,
  1004. py_Ref argv,
  1005. ) {
  1006. return _py_tpcall(
  1007. type,
  1008. argc,
  1009. argv,
  1010. );
  1011. }
  1012. late final _py_tpcallPtr =
  1013. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Type, ffi.Int, py_Ref)>>(
  1014. 'py_tpcall');
  1015. late final _py_tpcall =
  1016. _py_tpcallPtr.asFunction<bool Function(int, int, py_Ref)>();
  1017. /// Check if the object is an instance of the given type exactly.
  1018. /// Raise `TypeError` if the check fails.
  1019. bool py_checktype(
  1020. py_Ref self,
  1021. int type,
  1022. ) {
  1023. return _py_checktype(
  1024. self,
  1025. type,
  1026. );
  1027. }
  1028. late final _py_checktypePtr =
  1029. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Type)>>(
  1030. 'py_checktype');
  1031. late final _py_checktype =
  1032. _py_checktypePtr.asFunction<bool Function(py_Ref, int)>();
  1033. /// Check if the object is an instance of the given type or its subclass.
  1034. /// Raise `TypeError` if the check fails.
  1035. bool py_checkinstance(
  1036. py_Ref self,
  1037. int type,
  1038. ) {
  1039. return _py_checkinstance(
  1040. self,
  1041. type,
  1042. );
  1043. }
  1044. late final _py_checkinstancePtr =
  1045. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Type)>>(
  1046. 'py_checkinstance');
  1047. late final _py_checkinstance =
  1048. _py_checkinstancePtr.asFunction<bool Function(py_Ref, int)>();
  1049. /// Get the i-th register.
  1050. /// All registers are located in a contiguous memory.
  1051. py_GlobalRef py_getreg(
  1052. int i,
  1053. ) {
  1054. return _py_getreg(
  1055. i,
  1056. );
  1057. }
  1058. late final _py_getregPtr =
  1059. _lookup<ffi.NativeFunction<py_GlobalRef Function(ffi.Int)>>('py_getreg');
  1060. late final _py_getreg =
  1061. _py_getregPtr.asFunction<py_GlobalRef Function(int)>();
  1062. /// Set the i-th register.
  1063. void py_setreg(
  1064. int i,
  1065. py_Ref val,
  1066. ) {
  1067. return _py_setreg(
  1068. i,
  1069. val,
  1070. );
  1071. }
  1072. late final _py_setregPtr =
  1073. _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int, py_Ref)>>(
  1074. 'py_setreg');
  1075. late final _py_setreg =
  1076. _py_setregPtr.asFunction<void Function(int, py_Ref)>();
  1077. /// Get variable in the `__main__` module.
  1078. py_ItemRef py_getglobal(
  1079. int name,
  1080. ) {
  1081. return _py_getglobal(
  1082. name,
  1083. );
  1084. }
  1085. late final _py_getglobalPtr =
  1086. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Name)>>('py_getglobal');
  1087. late final _py_getglobal =
  1088. _py_getglobalPtr.asFunction<py_ItemRef Function(int)>();
  1089. /// Set variable in the `__main__` module.
  1090. void py_setglobal(
  1091. int name,
  1092. py_Ref val,
  1093. ) {
  1094. return _py_setglobal(
  1095. name,
  1096. val,
  1097. );
  1098. }
  1099. late final _py_setglobalPtr =
  1100. _lookup<ffi.NativeFunction<ffi.Void Function(py_Name, py_Ref)>>(
  1101. 'py_setglobal');
  1102. late final _py_setglobal =
  1103. _py_setglobalPtr.asFunction<void Function(int, py_Ref)>();
  1104. /// Get variable in the `builtins` module.
  1105. py_ItemRef py_getbuiltin(
  1106. int name,
  1107. ) {
  1108. return _py_getbuiltin(
  1109. name,
  1110. );
  1111. }
  1112. late final _py_getbuiltinPtr =
  1113. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Name)>>(
  1114. 'py_getbuiltin');
  1115. late final _py_getbuiltin =
  1116. _py_getbuiltinPtr.asFunction<py_ItemRef Function(int)>();
  1117. /// Equivalent to `*dst = *src`.
  1118. void py_assign(
  1119. py_Ref dst,
  1120. py_Ref src,
  1121. ) {
  1122. return _py_assign(
  1123. dst,
  1124. src,
  1125. );
  1126. }
  1127. late final _py_assignPtr =
  1128. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, py_Ref)>>(
  1129. 'py_assign');
  1130. late final _py_assign =
  1131. _py_assignPtr.asFunction<void Function(py_Ref, py_Ref)>();
  1132. /// Get the last return value.
  1133. py_GlobalRef py_retval() {
  1134. return _py_retval();
  1135. }
  1136. late final _py_retvalPtr =
  1137. _lookup<ffi.NativeFunction<py_GlobalRef Function()>>('py_retval');
  1138. late final _py_retval = _py_retvalPtr.asFunction<py_GlobalRef Function()>();
  1139. /// Get an item from the object's `__dict__`.
  1140. /// Return `NULL` if not found.
  1141. py_ItemRef py_getdict(
  1142. py_Ref self,
  1143. int name,
  1144. ) {
  1145. return _py_getdict(
  1146. self,
  1147. name,
  1148. );
  1149. }
  1150. late final _py_getdictPtr =
  1151. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Ref, py_Name)>>(
  1152. 'py_getdict');
  1153. late final _py_getdict =
  1154. _py_getdictPtr.asFunction<py_ItemRef Function(py_Ref, int)>();
  1155. /// Set an item to the object's `__dict__`.
  1156. void py_setdict(
  1157. py_Ref self,
  1158. int name,
  1159. py_Ref val,
  1160. ) {
  1161. return _py_setdict(
  1162. self,
  1163. name,
  1164. val,
  1165. );
  1166. }
  1167. late final _py_setdictPtr =
  1168. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, py_Name, py_Ref)>>(
  1169. 'py_setdict');
  1170. late final _py_setdict =
  1171. _py_setdictPtr.asFunction<void Function(py_Ref, int, py_Ref)>();
  1172. /// Delete an item from the object's `__dict__`.
  1173. /// Return `true` if the deletion is successful.
  1174. bool py_deldict(
  1175. py_Ref self,
  1176. int name,
  1177. ) {
  1178. return _py_deldict(
  1179. self,
  1180. name,
  1181. );
  1182. }
  1183. late final _py_deldictPtr =
  1184. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Name)>>(
  1185. 'py_deldict');
  1186. late final _py_deldict =
  1187. _py_deldictPtr.asFunction<bool Function(py_Ref, int)>();
  1188. /// Prepare an insertion to the object's `__dict__`.
  1189. py_ItemRef py_emplacedict(
  1190. py_Ref self,
  1191. int name,
  1192. ) {
  1193. return _py_emplacedict(
  1194. self,
  1195. name,
  1196. );
  1197. }
  1198. late final _py_emplacedictPtr =
  1199. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Ref, py_Name)>>(
  1200. 'py_emplacedict');
  1201. late final _py_emplacedict =
  1202. _py_emplacedictPtr.asFunction<py_ItemRef Function(py_Ref, int)>();
  1203. /// Apply a function to all items in the object's `__dict__`.
  1204. /// Return `true` if the function is successful for all items.
  1205. /// NOTE: Be careful if `f` modifies the object's `__dict__`.
  1206. bool py_applydict(
  1207. py_Ref self,
  1208. ffi.Pointer<
  1209. ffi.NativeFunction<
  1210. ffi.Bool Function(
  1211. py_Name name, py_Ref val, ffi.Pointer<ffi.Void> ctx)>>
  1212. f,
  1213. ffi.Pointer<ffi.Void> ctx,
  1214. ) {
  1215. return _py_applydict(
  1216. self,
  1217. f,
  1218. ctx,
  1219. );
  1220. }
  1221. late final _py_applydictPtr = _lookup<
  1222. ffi.NativeFunction<
  1223. ffi.Bool Function(
  1224. py_Ref,
  1225. ffi.Pointer<
  1226. ffi.NativeFunction<
  1227. ffi.Bool Function(py_Name name, py_Ref val,
  1228. ffi.Pointer<ffi.Void> ctx)>>,
  1229. ffi.Pointer<ffi.Void>)>>('py_applydict');
  1230. late final _py_applydict = _py_applydictPtr.asFunction<
  1231. bool Function(
  1232. py_Ref,
  1233. ffi.Pointer<
  1234. ffi.NativeFunction<
  1235. ffi.Bool Function(
  1236. py_Name name, py_Ref val, ffi.Pointer<ffi.Void> ctx)>>,
  1237. ffi.Pointer<ffi.Void>)>();
  1238. /// Get the i-th slot of the object.
  1239. /// The object must have slots and `i` must be in valid range.
  1240. py_ObjectRef py_getslot(
  1241. py_Ref self,
  1242. int i,
  1243. ) {
  1244. return _py_getslot(
  1245. self,
  1246. i,
  1247. );
  1248. }
  1249. late final _py_getslotPtr =
  1250. _lookup<ffi.NativeFunction<py_ObjectRef Function(py_Ref, ffi.Int)>>(
  1251. 'py_getslot');
  1252. late final _py_getslot =
  1253. _py_getslotPtr.asFunction<py_ObjectRef Function(py_Ref, int)>();
  1254. /// Set the i-th slot of the object.
  1255. void py_setslot(
  1256. py_Ref self,
  1257. int i,
  1258. py_Ref val,
  1259. ) {
  1260. return _py_setslot(
  1261. self,
  1262. i,
  1263. val,
  1264. );
  1265. }
  1266. late final _py_setslotPtr =
  1267. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int, py_Ref)>>(
  1268. 'py_setslot');
  1269. late final _py_setslot =
  1270. _py_setslotPtr.asFunction<void Function(py_Ref, int, py_Ref)>();
  1271. /// Get the current `function` object on the stack.
  1272. /// Return `NULL` if not available.
  1273. /// NOTE: This function should be placed at the beginning of your decl-based bindings.
  1274. py_StackRef py_inspect_currentfunction() {
  1275. return _py_inspect_currentfunction();
  1276. }
  1277. late final _py_inspect_currentfunctionPtr =
  1278. _lookup<ffi.NativeFunction<py_StackRef Function()>>(
  1279. 'py_inspect_currentfunction');
  1280. late final _py_inspect_currentfunction =
  1281. _py_inspect_currentfunctionPtr.asFunction<py_StackRef Function()>();
  1282. /// Get the current `module` object where the code is executed.
  1283. /// Return `NULL` if not available.
  1284. py_GlobalRef py_inspect_currentmodule() {
  1285. return _py_inspect_currentmodule();
  1286. }
  1287. late final _py_inspect_currentmodulePtr =
  1288. _lookup<ffi.NativeFunction<py_GlobalRef Function()>>(
  1289. 'py_inspect_currentmodule');
  1290. late final _py_inspect_currentmodule =
  1291. _py_inspect_currentmodulePtr.asFunction<py_GlobalRef Function()>();
  1292. /// Bind a function to the object via "decl-based" style.
  1293. /// @param obj the target object.
  1294. /// @param sig signature of the function. e.g. `add(x, y)`.
  1295. /// @param f function to bind.
  1296. void py_bind(
  1297. py_Ref obj,
  1298. ffi.Pointer<ffi.Char> sig,
  1299. py_CFunction f,
  1300. ) {
  1301. return _py_bind(
  1302. obj,
  1303. sig,
  1304. f,
  1305. );
  1306. }
  1307. late final _py_bindPtr = _lookup<
  1308. ffi.NativeFunction<
  1309. ffi.Void Function(
  1310. py_Ref, ffi.Pointer<ffi.Char>, py_CFunction)>>('py_bind');
  1311. late final _py_bind = _py_bindPtr
  1312. .asFunction<void Function(py_Ref, ffi.Pointer<ffi.Char>, py_CFunction)>();
  1313. /// Bind a method to type via "argc-based" style.
  1314. /// @param type the target type.
  1315. /// @param name name of the method.
  1316. /// @param f function to bind.
  1317. void py_bindmethod(
  1318. int type,
  1319. ffi.Pointer<ffi.Char> name,
  1320. py_CFunction f,
  1321. ) {
  1322. return _py_bindmethod(
  1323. type,
  1324. name,
  1325. f,
  1326. );
  1327. }
  1328. late final _py_bindmethodPtr = _lookup<
  1329. ffi.NativeFunction<
  1330. ffi.Void Function(
  1331. py_Type, ffi.Pointer<ffi.Char>, py_CFunction)>>('py_bindmethod');
  1332. late final _py_bindmethod = _py_bindmethodPtr
  1333. .asFunction<void Function(int, ffi.Pointer<ffi.Char>, py_CFunction)>();
  1334. /// Bind a static method to type via "argc-based" style.
  1335. /// @param type the target type.
  1336. /// @param name name of the method.
  1337. /// @param f function to bind.
  1338. void py_bindstaticmethod(
  1339. int type,
  1340. ffi.Pointer<ffi.Char> name,
  1341. py_CFunction f,
  1342. ) {
  1343. return _py_bindstaticmethod(
  1344. type,
  1345. name,
  1346. f,
  1347. );
  1348. }
  1349. late final _py_bindstaticmethodPtr = _lookup<
  1350. ffi.NativeFunction<
  1351. ffi.Void Function(py_Type, ffi.Pointer<ffi.Char>,
  1352. py_CFunction)>>('py_bindstaticmethod');
  1353. late final _py_bindstaticmethod = _py_bindstaticmethodPtr
  1354. .asFunction<void Function(int, ffi.Pointer<ffi.Char>, py_CFunction)>();
  1355. /// Bind a function to the object via "argc-based" style.
  1356. /// @param obj the target object.
  1357. /// @param name name of the function.
  1358. /// @param f function to bind.
  1359. void py_bindfunc(
  1360. py_Ref obj,
  1361. ffi.Pointer<ffi.Char> name,
  1362. py_CFunction f,
  1363. ) {
  1364. return _py_bindfunc(
  1365. obj,
  1366. name,
  1367. f,
  1368. );
  1369. }
  1370. late final _py_bindfuncPtr = _lookup<
  1371. ffi.NativeFunction<
  1372. ffi.Void Function(
  1373. py_Ref, ffi.Pointer<ffi.Char>, py_CFunction)>>('py_bindfunc');
  1374. late final _py_bindfunc = _py_bindfuncPtr
  1375. .asFunction<void Function(py_Ref, ffi.Pointer<ffi.Char>, py_CFunction)>();
  1376. /// Bind a property to type.
  1377. /// @param type the target type.
  1378. /// @param name name of the property.
  1379. /// @param getter getter function.
  1380. /// @param setter setter function. Use `NULL` if not needed.
  1381. void py_bindproperty(
  1382. int type,
  1383. ffi.Pointer<ffi.Char> name,
  1384. py_CFunction getter,
  1385. py_CFunction setter,
  1386. ) {
  1387. return _py_bindproperty(
  1388. type,
  1389. name,
  1390. getter,
  1391. setter,
  1392. );
  1393. }
  1394. late final _py_bindpropertyPtr = _lookup<
  1395. ffi.NativeFunction<
  1396. ffi.Void Function(py_Type, ffi.Pointer<ffi.Char>, py_CFunction,
  1397. py_CFunction)>>('py_bindproperty');
  1398. late final _py_bindproperty = _py_bindpropertyPtr.asFunction<
  1399. void Function(int, ffi.Pointer<ffi.Char>, py_CFunction, py_CFunction)>();
  1400. /// Python equivalent to `getattr(self, name)`.
  1401. bool py_getattr(
  1402. py_Ref self,
  1403. int name,
  1404. ) {
  1405. return _py_getattr(
  1406. self,
  1407. name,
  1408. );
  1409. }
  1410. late final _py_getattrPtr =
  1411. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Name)>>(
  1412. 'py_getattr');
  1413. late final _py_getattr =
  1414. _py_getattrPtr.asFunction<bool Function(py_Ref, int)>();
  1415. /// Python equivalent to `setattr(self, name, val)`.
  1416. bool py_setattr(
  1417. py_Ref self,
  1418. int name,
  1419. py_Ref val,
  1420. ) {
  1421. return _py_setattr(
  1422. self,
  1423. name,
  1424. val,
  1425. );
  1426. }
  1427. late final _py_setattrPtr =
  1428. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Name, py_Ref)>>(
  1429. 'py_setattr');
  1430. late final _py_setattr =
  1431. _py_setattrPtr.asFunction<bool Function(py_Ref, int, py_Ref)>();
  1432. /// Python equivalent to `delattr(self, name)`.
  1433. bool py_delattr(
  1434. py_Ref self,
  1435. int name,
  1436. ) {
  1437. return _py_delattr(
  1438. self,
  1439. name,
  1440. );
  1441. }
  1442. late final _py_delattrPtr =
  1443. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Name)>>(
  1444. 'py_delattr');
  1445. late final _py_delattr =
  1446. _py_delattrPtr.asFunction<bool Function(py_Ref, int)>();
  1447. /// Python equivalent to `self[key]`.
  1448. bool py_getitem(
  1449. py_Ref self,
  1450. py_Ref key,
  1451. ) {
  1452. return _py_getitem(
  1453. self,
  1454. key,
  1455. );
  1456. }
  1457. late final _py_getitemPtr =
  1458. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1459. 'py_getitem');
  1460. late final _py_getitem =
  1461. _py_getitemPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1462. /// Python equivalent to `self[key] = val`.
  1463. bool py_setitem(
  1464. py_Ref self,
  1465. py_Ref key,
  1466. py_Ref val,
  1467. ) {
  1468. return _py_setitem(
  1469. self,
  1470. key,
  1471. val,
  1472. );
  1473. }
  1474. late final _py_setitemPtr =
  1475. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref, py_Ref)>>(
  1476. 'py_setitem');
  1477. late final _py_setitem =
  1478. _py_setitemPtr.asFunction<bool Function(py_Ref, py_Ref, py_Ref)>();
  1479. /// Python equivalent to `del self[key]`.
  1480. bool py_delitem(
  1481. py_Ref self,
  1482. py_Ref key,
  1483. ) {
  1484. return _py_delitem(
  1485. self,
  1486. key,
  1487. );
  1488. }
  1489. late final _py_delitemPtr =
  1490. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1491. 'py_delitem');
  1492. late final _py_delitem =
  1493. _py_delitemPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1494. /// Perform a binary operation.
  1495. /// The result will be set to `py_retval()`.
  1496. /// The stack remains unchanged after the operation.
  1497. bool py_binaryop(
  1498. py_Ref lhs,
  1499. py_Ref rhs,
  1500. int op,
  1501. int rop,
  1502. ) {
  1503. return _py_binaryop(
  1504. lhs,
  1505. rhs,
  1506. op,
  1507. rop,
  1508. );
  1509. }
  1510. late final _py_binaryopPtr = _lookup<
  1511. ffi.NativeFunction<
  1512. ffi.Bool Function(py_Ref, py_Ref, py_Name, py_Name)>>('py_binaryop');
  1513. late final _py_binaryop =
  1514. _py_binaryopPtr.asFunction<bool Function(py_Ref, py_Ref, int, int)>();
  1515. /// Get the i-th object from the top of the stack.
  1516. /// `i` should be negative, e.g. (-1) means TOS.
  1517. py_StackRef py_peek(
  1518. int i,
  1519. ) {
  1520. return _py_peek(
  1521. i,
  1522. );
  1523. }
  1524. late final _py_peekPtr =
  1525. _lookup<ffi.NativeFunction<py_StackRef Function(ffi.Int)>>('py_peek');
  1526. late final _py_peek = _py_peekPtr.asFunction<py_StackRef Function(int)>();
  1527. /// Push the object to the stack.
  1528. void py_push(
  1529. py_Ref src,
  1530. ) {
  1531. return _py_push(
  1532. src,
  1533. );
  1534. }
  1535. late final _py_pushPtr =
  1536. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref)>>('py_push');
  1537. late final _py_push = _py_pushPtr.asFunction<void Function(py_Ref)>();
  1538. /// Push a `nil` object to the stack.
  1539. void py_pushnil() {
  1540. return _py_pushnil();
  1541. }
  1542. late final _py_pushnilPtr =
  1543. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_pushnil');
  1544. late final _py_pushnil = _py_pushnilPtr.asFunction<void Function()>();
  1545. /// Push a `None` object to the stack.
  1546. void py_pushnone() {
  1547. return _py_pushnone();
  1548. }
  1549. late final _py_pushnonePtr =
  1550. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_pushnone');
  1551. late final _py_pushnone = _py_pushnonePtr.asFunction<void Function()>();
  1552. /// Push a `py_Name` to the stack. This is used for keyword arguments.
  1553. void py_pushname(
  1554. int name,
  1555. ) {
  1556. return _py_pushname(
  1557. name,
  1558. );
  1559. }
  1560. late final _py_pushnamePtr =
  1561. _lookup<ffi.NativeFunction<ffi.Void Function(py_Name)>>('py_pushname');
  1562. late final _py_pushname = _py_pushnamePtr.asFunction<void Function(int)>();
  1563. /// Pop an object from the stack.
  1564. void py_pop() {
  1565. return _py_pop();
  1566. }
  1567. late final _py_popPtr =
  1568. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_pop');
  1569. late final _py_pop = _py_popPtr.asFunction<void Function()>();
  1570. /// Shrink the stack by n.
  1571. void py_shrink(
  1572. int n,
  1573. ) {
  1574. return _py_shrink(
  1575. n,
  1576. );
  1577. }
  1578. late final _py_shrinkPtr =
  1579. _lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int)>>('py_shrink');
  1580. late final _py_shrink = _py_shrinkPtr.asFunction<void Function(int)>();
  1581. /// Get a temporary variable from the stack.
  1582. py_StackRef py_pushtmp() {
  1583. return _py_pushtmp();
  1584. }
  1585. late final _py_pushtmpPtr =
  1586. _lookup<ffi.NativeFunction<py_StackRef Function()>>('py_pushtmp');
  1587. late final _py_pushtmp = _py_pushtmpPtr.asFunction<py_StackRef Function()>();
  1588. /// Get the unbound method of the object.
  1589. /// Assume the object is located at the top of the stack.
  1590. /// If return true: `[self] -> [unbound, self]`.
  1591. /// If return false: `[self] -> [self]` (no change).
  1592. bool py_pushmethod(
  1593. int name,
  1594. ) {
  1595. return _py_pushmethod(
  1596. name,
  1597. );
  1598. }
  1599. late final _py_pushmethodPtr =
  1600. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Name)>>('py_pushmethod');
  1601. late final _py_pushmethod =
  1602. _py_pushmethodPtr.asFunction<bool Function(int)>();
  1603. /// Call a callable object via pocketpy's calling convention.
  1604. /// You need to prepare the stack using this form: `callable, self/nil, arg1, arg2, ..., k1, v1, k2, v2, ...`
  1605. /// `argc` is the number of positional arguments excluding `self`.
  1606. /// `kwargc` is the number of keyword arguments, i.e. the number of key-value pairs.
  1607. /// The result will be set to `py_retval()`.
  1608. /// The stack size will be reduced by `2 + argc + kwargc * 2`.
  1609. bool py_vectorcall(
  1610. int argc,
  1611. int kwargc,
  1612. ) {
  1613. return _py_vectorcall(
  1614. argc,
  1615. kwargc,
  1616. );
  1617. }
  1618. late final _py_vectorcallPtr =
  1619. _lookup<ffi.NativeFunction<ffi.Bool Function(ffi.Uint16, ffi.Uint16)>>(
  1620. 'py_vectorcall');
  1621. late final _py_vectorcall =
  1622. _py_vectorcallPtr.asFunction<bool Function(int, int)>();
  1623. /// Evaluate an expression and push the result to the stack.
  1624. /// This function is used for testing.
  1625. bool py_pusheval(
  1626. ffi.Pointer<ffi.Char> expr,
  1627. py_GlobalRef module,
  1628. ) {
  1629. return _py_pusheval(
  1630. expr,
  1631. module,
  1632. );
  1633. }
  1634. late final _py_pushevalPtr = _lookup<
  1635. ffi.NativeFunction<
  1636. ffi.Bool Function(
  1637. ffi.Pointer<ffi.Char>, py_GlobalRef)>>('py_pusheval');
  1638. late final _py_pusheval = _py_pushevalPtr
  1639. .asFunction<bool Function(ffi.Pointer<ffi.Char>, py_GlobalRef)>();
  1640. /// Create a new module.
  1641. py_GlobalRef py_newmodule(
  1642. ffi.Pointer<ffi.Char> path,
  1643. ) {
  1644. return _py_newmodule(
  1645. path,
  1646. );
  1647. }
  1648. late final _py_newmodulePtr =
  1649. _lookup<ffi.NativeFunction<py_GlobalRef Function(ffi.Pointer<ffi.Char>)>>(
  1650. 'py_newmodule');
  1651. late final _py_newmodule = _py_newmodulePtr
  1652. .asFunction<py_GlobalRef Function(ffi.Pointer<ffi.Char>)>();
  1653. /// Get a module by path.
  1654. py_GlobalRef py_getmodule(
  1655. ffi.Pointer<ffi.Char> path,
  1656. ) {
  1657. return _py_getmodule(
  1658. path,
  1659. );
  1660. }
  1661. late final _py_getmodulePtr =
  1662. _lookup<ffi.NativeFunction<py_GlobalRef Function(ffi.Pointer<ffi.Char>)>>(
  1663. 'py_getmodule');
  1664. late final _py_getmodule = _py_getmodulePtr
  1665. .asFunction<py_GlobalRef Function(ffi.Pointer<ffi.Char>)>();
  1666. /// Reload an existing module.
  1667. bool py_importlib_reload(
  1668. py_GlobalRef module,
  1669. ) {
  1670. return _py_importlib_reload(
  1671. module,
  1672. );
  1673. }
  1674. late final _py_importlib_reloadPtr =
  1675. _lookup<ffi.NativeFunction<ffi.Bool Function(py_GlobalRef)>>(
  1676. 'py_importlib_reload');
  1677. late final _py_importlib_reload =
  1678. _py_importlib_reloadPtr.asFunction<bool Function(py_GlobalRef)>();
  1679. /// Import a module.
  1680. /// The result will be set to `py_retval()`.
  1681. /// -1: error, 0: not found, 1: success
  1682. int py_import(
  1683. ffi.Pointer<ffi.Char> path,
  1684. ) {
  1685. return _py_import(
  1686. path,
  1687. );
  1688. }
  1689. late final _py_importPtr =
  1690. _lookup<ffi.NativeFunction<ffi.Int Function(ffi.Pointer<ffi.Char>)>>(
  1691. 'py_import');
  1692. late final _py_import =
  1693. _py_importPtr.asFunction<int Function(ffi.Pointer<ffi.Char>)>();
  1694. /// Raise an exception by type and message. Always return false.
  1695. bool py_exception(
  1696. int type,
  1697. ffi.Pointer<ffi.Char> fmt,
  1698. ) {
  1699. return _py_exception(
  1700. type,
  1701. fmt,
  1702. );
  1703. }
  1704. late final _py_exceptionPtr = _lookup<
  1705. ffi.NativeFunction<
  1706. ffi.Bool Function(py_Type, ffi.Pointer<ffi.Char>)>>('py_exception');
  1707. late final _py_exception =
  1708. _py_exceptionPtr.asFunction<bool Function(int, ffi.Pointer<ffi.Char>)>();
  1709. /// Raise an expection object. Always return false.
  1710. bool py_raise(
  1711. py_Ref arg0,
  1712. ) {
  1713. return _py_raise(
  1714. arg0,
  1715. );
  1716. }
  1717. late final _py_raisePtr =
  1718. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_raise');
  1719. late final _py_raise = _py_raisePtr.asFunction<bool Function(py_Ref)>();
  1720. /// Print the current exception.
  1721. /// The exception will be set as handled.
  1722. void py_printexc() {
  1723. return _py_printexc();
  1724. }
  1725. late final _py_printexcPtr =
  1726. _lookup<ffi.NativeFunction<ffi.Void Function()>>('py_printexc');
  1727. late final _py_printexc = _py_printexcPtr.asFunction<void Function()>();
  1728. /// Format the current exception and return a null-terminated string.
  1729. /// The result should be freed by the caller.
  1730. /// The exception will be set as handled.
  1731. ffi.Pointer<ffi.Char> py_formatexc() {
  1732. return _py_formatexc();
  1733. }
  1734. late final _py_formatexcPtr =
  1735. _lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
  1736. 'py_formatexc');
  1737. late final _py_formatexc =
  1738. _py_formatexcPtr.asFunction<ffi.Pointer<ffi.Char> Function()>();
  1739. /// Check if an exception is raised.
  1740. bool py_checkexc(
  1741. bool ignore_handled,
  1742. ) {
  1743. return _py_checkexc(
  1744. ignore_handled,
  1745. );
  1746. }
  1747. late final _py_checkexcPtr =
  1748. _lookup<ffi.NativeFunction<ffi.Bool Function(ffi.Bool)>>('py_checkexc');
  1749. late final _py_checkexc = _py_checkexcPtr.asFunction<bool Function(bool)>();
  1750. /// Check if the exception is an instance of the given type.
  1751. /// This function is roughly equivalent to python's `except <T> as e:` block.
  1752. /// If match, the exception will be stored in `py_retval()` as handled.
  1753. bool py_matchexc(
  1754. int type,
  1755. ) {
  1756. return _py_matchexc(
  1757. type,
  1758. );
  1759. }
  1760. late final _py_matchexcPtr =
  1761. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Type)>>('py_matchexc');
  1762. late final _py_matchexc = _py_matchexcPtr.asFunction<bool Function(int)>();
  1763. /// Clear the current exception.
  1764. /// @param p0 the unwinding point. Use `NULL` if not needed.
  1765. void py_clearexc(
  1766. py_StackRef p0,
  1767. ) {
  1768. return _py_clearexc(
  1769. p0,
  1770. );
  1771. }
  1772. late final _py_clearexcPtr =
  1773. _lookup<ffi.NativeFunction<ffi.Void Function(py_StackRef)>>(
  1774. 'py_clearexc');
  1775. late final _py_clearexc =
  1776. _py_clearexcPtr.asFunction<void Function(py_StackRef)>();
  1777. bool StopIteration() {
  1778. return _StopIteration();
  1779. }
  1780. late final _StopIterationPtr =
  1781. _lookup<ffi.NativeFunction<ffi.Bool Function()>>('StopIteration');
  1782. late final _StopIteration = _StopIterationPtr.asFunction<bool Function()>();
  1783. bool KeyError(
  1784. py_Ref key,
  1785. ) {
  1786. return _KeyError(
  1787. key,
  1788. );
  1789. }
  1790. late final _KeyErrorPtr =
  1791. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('KeyError');
  1792. late final _KeyError = _KeyErrorPtr.asFunction<bool Function(py_Ref)>();
  1793. /// Python equivalent to `bool(val)`.
  1794. /// 1: true, 0: false, -1: error
  1795. int py_bool(
  1796. py_Ref val,
  1797. ) {
  1798. return _py_bool(
  1799. val,
  1800. );
  1801. }
  1802. late final _py_boolPtr =
  1803. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref)>>('py_bool');
  1804. late final _py_bool = _py_boolPtr.asFunction<int Function(py_Ref)>();
  1805. /// Compare two objects.
  1806. /// 1: lhs == rhs, 0: lhs != rhs, -1: error
  1807. int py_equal(
  1808. py_Ref lhs,
  1809. py_Ref rhs,
  1810. ) {
  1811. return _py_equal(
  1812. lhs,
  1813. rhs,
  1814. );
  1815. }
  1816. late final _py_equalPtr =
  1817. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref, py_Ref)>>('py_equal');
  1818. late final _py_equal =
  1819. _py_equalPtr.asFunction<int Function(py_Ref, py_Ref)>();
  1820. /// Compare two objects.
  1821. /// 1: lhs < rhs, 0: lhs >= rhs, -1: error
  1822. int py_less(
  1823. py_Ref lhs,
  1824. py_Ref rhs,
  1825. ) {
  1826. return _py_less(
  1827. lhs,
  1828. rhs,
  1829. );
  1830. }
  1831. late final _py_lessPtr =
  1832. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref, py_Ref)>>('py_less');
  1833. late final _py_less = _py_lessPtr.asFunction<int Function(py_Ref, py_Ref)>();
  1834. /// Python equivalent to `callable(val)`.
  1835. bool py_callable(
  1836. py_Ref val,
  1837. ) {
  1838. return _py_callable(
  1839. val,
  1840. );
  1841. }
  1842. late final _py_callablePtr =
  1843. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_callable');
  1844. late final _py_callable = _py_callablePtr.asFunction<bool Function(py_Ref)>();
  1845. /// Get the hash value of the object.
  1846. bool py_hash(
  1847. py_Ref arg0,
  1848. ffi.Pointer<py_i64> out,
  1849. ) {
  1850. return _py_hash(
  1851. arg0,
  1852. out,
  1853. );
  1854. }
  1855. late final _py_hashPtr = _lookup<
  1856. ffi.NativeFunction<ffi.Bool Function(py_Ref, ffi.Pointer<py_i64>)>>(
  1857. 'py_hash');
  1858. late final _py_hash =
  1859. _py_hashPtr.asFunction<bool Function(py_Ref, ffi.Pointer<py_i64>)>();
  1860. /// Get the iterator of the object.
  1861. bool py_iter(
  1862. py_Ref arg0,
  1863. ) {
  1864. return _py_iter(
  1865. arg0,
  1866. );
  1867. }
  1868. late final _py_iterPtr =
  1869. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_iter');
  1870. late final _py_iter = _py_iterPtr.asFunction<bool Function(py_Ref)>();
  1871. /// Get the next element from the iterator.
  1872. /// 1: success, 0: StopIteration, -1: error
  1873. int py_next(
  1874. py_Ref arg0,
  1875. ) {
  1876. return _py_next(
  1877. arg0,
  1878. );
  1879. }
  1880. late final _py_nextPtr =
  1881. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref)>>('py_next');
  1882. late final _py_next = _py_nextPtr.asFunction<int Function(py_Ref)>();
  1883. /// Python equivalent to `lhs is rhs`.
  1884. bool py_isidentical(
  1885. py_Ref arg0,
  1886. py_Ref arg1,
  1887. ) {
  1888. return _py_isidentical(
  1889. arg0,
  1890. arg1,
  1891. );
  1892. }
  1893. late final _py_isidenticalPtr =
  1894. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref)>>(
  1895. 'py_isidentical');
  1896. late final _py_isidentical =
  1897. _py_isidenticalPtr.asFunction<bool Function(py_Ref, py_Ref)>();
  1898. /// Call a function.
  1899. /// It prepares the stack and then performs a `vectorcall(argc, 0, false)`.
  1900. /// The result will be set to `py_retval()`.
  1901. /// The stack remains unchanged after the operation.
  1902. bool py_call(
  1903. py_Ref f,
  1904. int argc,
  1905. py_Ref argv,
  1906. ) {
  1907. return _py_call(
  1908. f,
  1909. argc,
  1910. argv,
  1911. );
  1912. }
  1913. late final _py_callPtr =
  1914. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, ffi.Int, py_Ref)>>(
  1915. 'py_call');
  1916. late final _py_call =
  1917. _py_callPtr.asFunction<bool Function(py_Ref, int, py_Ref)>();
  1918. /// Call a `py_CFunction` in a safe way.
  1919. /// This function does extra checks to help you debug `py_CFunction`.
  1920. bool py_callcfunc(
  1921. py_CFunction f,
  1922. int argc,
  1923. py_Ref argv,
  1924. ) {
  1925. return _py_callcfunc(
  1926. f,
  1927. argc,
  1928. argv,
  1929. );
  1930. }
  1931. late final _py_callcfuncPtr = _lookup<
  1932. ffi.NativeFunction<ffi.Bool Function(py_CFunction, ffi.Int, py_Ref)>>(
  1933. 'py_callcfunc');
  1934. late final _py_callcfunc =
  1935. _py_callcfuncPtr.asFunction<bool Function(py_CFunction, int, py_Ref)>();
  1936. /// Python equivalent to `str(val)`.
  1937. bool py_str(
  1938. py_Ref val,
  1939. ) {
  1940. return _py_str(
  1941. val,
  1942. );
  1943. }
  1944. late final _py_strPtr =
  1945. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_str');
  1946. late final _py_str = _py_strPtr.asFunction<bool Function(py_Ref)>();
  1947. /// Python equivalent to `repr(val)`.
  1948. bool py_repr(
  1949. py_Ref val,
  1950. ) {
  1951. return _py_repr(
  1952. val,
  1953. );
  1954. }
  1955. late final _py_reprPtr =
  1956. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_repr');
  1957. late final _py_repr = _py_reprPtr.asFunction<bool Function(py_Ref)>();
  1958. /// Python equivalent to `len(val)`.
  1959. bool py_len(
  1960. py_Ref val,
  1961. ) {
  1962. return _py_len(
  1963. val,
  1964. );
  1965. }
  1966. late final _py_lenPtr =
  1967. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_len');
  1968. late final _py_len = _py_lenPtr.asFunction<bool Function(py_Ref)>();
  1969. /// Python equivalent to `json.dumps(val)`.
  1970. bool py_json_dumps(
  1971. py_Ref val,
  1972. ) {
  1973. return _py_json_dumps(
  1974. val,
  1975. );
  1976. }
  1977. late final _py_json_dumpsPtr =
  1978. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_json_dumps');
  1979. late final _py_json_dumps =
  1980. _py_json_dumpsPtr.asFunction<bool Function(py_Ref)>();
  1981. /// Python equivalent to `json.loads(val)`.
  1982. bool py_json_loads(
  1983. ffi.Pointer<ffi.Char> source,
  1984. ) {
  1985. return _py_json_loads(
  1986. source,
  1987. );
  1988. }
  1989. late final _py_json_loadsPtr =
  1990. _lookup<ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Char>)>>(
  1991. 'py_json_loads');
  1992. late final _py_json_loads =
  1993. _py_json_loadsPtr.asFunction<bool Function(ffi.Pointer<ffi.Char>)>();
  1994. /// Python equivalent to `pickle.dumps(val)`.
  1995. bool py_pickle_dumps(
  1996. py_Ref val,
  1997. ) {
  1998. return _py_pickle_dumps(
  1999. val,
  2000. );
  2001. }
  2002. late final _py_pickle_dumpsPtr =
  2003. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref)>>('py_pickle_dumps');
  2004. late final _py_pickle_dumps =
  2005. _py_pickle_dumpsPtr.asFunction<bool Function(py_Ref)>();
  2006. /// Python equivalent to `pickle.loads(val)`.
  2007. bool py_pickle_loads(
  2008. ffi.Pointer<ffi.UnsignedChar> data,
  2009. int size,
  2010. ) {
  2011. return _py_pickle_loads(
  2012. data,
  2013. size,
  2014. );
  2015. }
  2016. late final _py_pickle_loadsPtr = _lookup<
  2017. ffi.NativeFunction<
  2018. ffi.Bool Function(
  2019. ffi.Pointer<ffi.UnsignedChar>, ffi.Int)>>('py_pickle_loads');
  2020. late final _py_pickle_loads = _py_pickle_loadsPtr
  2021. .asFunction<bool Function(ffi.Pointer<ffi.UnsignedChar>, int)>();
  2022. /// Unchecked Functions
  2023. py_ObjectRef py_tuple_data(
  2024. py_Ref self,
  2025. ) {
  2026. return _py_tuple_data(
  2027. self,
  2028. );
  2029. }
  2030. late final _py_tuple_dataPtr =
  2031. _lookup<ffi.NativeFunction<py_ObjectRef Function(py_Ref)>>(
  2032. 'py_tuple_data');
  2033. late final _py_tuple_data =
  2034. _py_tuple_dataPtr.asFunction<py_ObjectRef Function(py_Ref)>();
  2035. py_ObjectRef py_tuple_getitem(
  2036. py_Ref self,
  2037. int i,
  2038. ) {
  2039. return _py_tuple_getitem(
  2040. self,
  2041. i,
  2042. );
  2043. }
  2044. late final _py_tuple_getitemPtr =
  2045. _lookup<ffi.NativeFunction<py_ObjectRef Function(py_Ref, ffi.Int)>>(
  2046. 'py_tuple_getitem');
  2047. late final _py_tuple_getitem =
  2048. _py_tuple_getitemPtr.asFunction<py_ObjectRef Function(py_Ref, int)>();
  2049. void py_tuple_setitem(
  2050. py_Ref self,
  2051. int i,
  2052. py_Ref val,
  2053. ) {
  2054. return _py_tuple_setitem(
  2055. self,
  2056. i,
  2057. val,
  2058. );
  2059. }
  2060. late final _py_tuple_setitemPtr =
  2061. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int, py_Ref)>>(
  2062. 'py_tuple_setitem');
  2063. late final _py_tuple_setitem =
  2064. _py_tuple_setitemPtr.asFunction<void Function(py_Ref, int, py_Ref)>();
  2065. int py_tuple_len(
  2066. py_Ref self,
  2067. ) {
  2068. return _py_tuple_len(
  2069. self,
  2070. );
  2071. }
  2072. late final _py_tuple_lenPtr =
  2073. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref)>>('py_tuple_len');
  2074. late final _py_tuple_len =
  2075. _py_tuple_lenPtr.asFunction<int Function(py_Ref)>();
  2076. py_ItemRef py_list_data(
  2077. py_Ref self,
  2078. ) {
  2079. return _py_list_data(
  2080. self,
  2081. );
  2082. }
  2083. late final _py_list_dataPtr =
  2084. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Ref)>>('py_list_data');
  2085. late final _py_list_data =
  2086. _py_list_dataPtr.asFunction<py_ItemRef Function(py_Ref)>();
  2087. py_ItemRef py_list_getitem(
  2088. py_Ref self,
  2089. int i,
  2090. ) {
  2091. return _py_list_getitem(
  2092. self,
  2093. i,
  2094. );
  2095. }
  2096. late final _py_list_getitemPtr =
  2097. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Ref, ffi.Int)>>(
  2098. 'py_list_getitem');
  2099. late final _py_list_getitem =
  2100. _py_list_getitemPtr.asFunction<py_ItemRef Function(py_Ref, int)>();
  2101. void py_list_setitem(
  2102. py_Ref self,
  2103. int i,
  2104. py_Ref val,
  2105. ) {
  2106. return _py_list_setitem(
  2107. self,
  2108. i,
  2109. val,
  2110. );
  2111. }
  2112. late final _py_list_setitemPtr =
  2113. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int, py_Ref)>>(
  2114. 'py_list_setitem');
  2115. late final _py_list_setitem =
  2116. _py_list_setitemPtr.asFunction<void Function(py_Ref, int, py_Ref)>();
  2117. void py_list_delitem(
  2118. py_Ref self,
  2119. int i,
  2120. ) {
  2121. return _py_list_delitem(
  2122. self,
  2123. i,
  2124. );
  2125. }
  2126. late final _py_list_delitemPtr =
  2127. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int)>>(
  2128. 'py_list_delitem');
  2129. late final _py_list_delitem =
  2130. _py_list_delitemPtr.asFunction<void Function(py_Ref, int)>();
  2131. int py_list_len(
  2132. py_Ref self,
  2133. ) {
  2134. return _py_list_len(
  2135. self,
  2136. );
  2137. }
  2138. late final _py_list_lenPtr =
  2139. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref)>>('py_list_len');
  2140. late final _py_list_len = _py_list_lenPtr.asFunction<int Function(py_Ref)>();
  2141. void py_list_swap(
  2142. py_Ref self,
  2143. int i,
  2144. int j,
  2145. ) {
  2146. return _py_list_swap(
  2147. self,
  2148. i,
  2149. j,
  2150. );
  2151. }
  2152. late final _py_list_swapPtr =
  2153. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int, ffi.Int)>>(
  2154. 'py_list_swap');
  2155. late final _py_list_swap =
  2156. _py_list_swapPtr.asFunction<void Function(py_Ref, int, int)>();
  2157. void py_list_append(
  2158. py_Ref self,
  2159. py_Ref val,
  2160. ) {
  2161. return _py_list_append(
  2162. self,
  2163. val,
  2164. );
  2165. }
  2166. late final _py_list_appendPtr =
  2167. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, py_Ref)>>(
  2168. 'py_list_append');
  2169. late final _py_list_append =
  2170. _py_list_appendPtr.asFunction<void Function(py_Ref, py_Ref)>();
  2171. py_ItemRef py_list_emplace(
  2172. py_Ref self,
  2173. ) {
  2174. return _py_list_emplace(
  2175. self,
  2176. );
  2177. }
  2178. late final _py_list_emplacePtr =
  2179. _lookup<ffi.NativeFunction<py_ItemRef Function(py_Ref)>>(
  2180. 'py_list_emplace');
  2181. late final _py_list_emplace =
  2182. _py_list_emplacePtr.asFunction<py_ItemRef Function(py_Ref)>();
  2183. void py_list_clear(
  2184. py_Ref self,
  2185. ) {
  2186. return _py_list_clear(
  2187. self,
  2188. );
  2189. }
  2190. late final _py_list_clearPtr =
  2191. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref)>>('py_list_clear');
  2192. late final _py_list_clear =
  2193. _py_list_clearPtr.asFunction<void Function(py_Ref)>();
  2194. void py_list_insert(
  2195. py_Ref self,
  2196. int i,
  2197. py_Ref val,
  2198. ) {
  2199. return _py_list_insert(
  2200. self,
  2201. i,
  2202. val,
  2203. );
  2204. }
  2205. late final _py_list_insertPtr =
  2206. _lookup<ffi.NativeFunction<ffi.Void Function(py_Ref, ffi.Int, py_Ref)>>(
  2207. 'py_list_insert');
  2208. late final _py_list_insert =
  2209. _py_list_insertPtr.asFunction<void Function(py_Ref, int, py_Ref)>();
  2210. /// -1: error, 0: not found, 1: found
  2211. int py_dict_getitem(
  2212. py_Ref self,
  2213. py_Ref key,
  2214. ) {
  2215. return _py_dict_getitem(
  2216. self,
  2217. key,
  2218. );
  2219. }
  2220. late final _py_dict_getitemPtr =
  2221. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref, py_Ref)>>(
  2222. 'py_dict_getitem');
  2223. late final _py_dict_getitem =
  2224. _py_dict_getitemPtr.asFunction<int Function(py_Ref, py_Ref)>();
  2225. /// true: success, false: error
  2226. bool py_dict_setitem(
  2227. py_Ref self,
  2228. py_Ref key,
  2229. py_Ref val,
  2230. ) {
  2231. return _py_dict_setitem(
  2232. self,
  2233. key,
  2234. val,
  2235. );
  2236. }
  2237. late final _py_dict_setitemPtr =
  2238. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_Ref, py_Ref)>>(
  2239. 'py_dict_setitem');
  2240. late final _py_dict_setitem =
  2241. _py_dict_setitemPtr.asFunction<bool Function(py_Ref, py_Ref, py_Ref)>();
  2242. /// -1: error, 0: not found, 1: found (and deleted)
  2243. int py_dict_delitem(
  2244. py_Ref self,
  2245. py_Ref key,
  2246. ) {
  2247. return _py_dict_delitem(
  2248. self,
  2249. key,
  2250. );
  2251. }
  2252. late final _py_dict_delitemPtr =
  2253. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref, py_Ref)>>(
  2254. 'py_dict_delitem');
  2255. late final _py_dict_delitem =
  2256. _py_dict_delitemPtr.asFunction<int Function(py_Ref, py_Ref)>();
  2257. /// -1: error, 0: not found, 1: found
  2258. int py_dict_getitem_by_str(
  2259. py_Ref self,
  2260. ffi.Pointer<ffi.Char> key,
  2261. ) {
  2262. return _py_dict_getitem_by_str(
  2263. self,
  2264. key,
  2265. );
  2266. }
  2267. late final _py_dict_getitem_by_strPtr = _lookup<
  2268. ffi.NativeFunction<ffi.Int Function(py_Ref, ffi.Pointer<ffi.Char>)>>(
  2269. 'py_dict_getitem_by_str');
  2270. late final _py_dict_getitem_by_str = _py_dict_getitem_by_strPtr
  2271. .asFunction<int Function(py_Ref, ffi.Pointer<ffi.Char>)>();
  2272. /// -1: error, 0: not found, 1: found
  2273. int py_dict_getitem_by_int(
  2274. py_Ref self,
  2275. int key,
  2276. ) {
  2277. return _py_dict_getitem_by_int(
  2278. self,
  2279. key,
  2280. );
  2281. }
  2282. late final _py_dict_getitem_by_intPtr =
  2283. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref, py_i64)>>(
  2284. 'py_dict_getitem_by_int');
  2285. late final _py_dict_getitem_by_int =
  2286. _py_dict_getitem_by_intPtr.asFunction<int Function(py_Ref, int)>();
  2287. /// true: success, false: error
  2288. bool py_dict_setitem_by_str(
  2289. py_Ref self,
  2290. ffi.Pointer<ffi.Char> key,
  2291. py_Ref val,
  2292. ) {
  2293. return _py_dict_setitem_by_str(
  2294. self,
  2295. key,
  2296. val,
  2297. );
  2298. }
  2299. late final _py_dict_setitem_by_strPtr = _lookup<
  2300. ffi.NativeFunction<
  2301. ffi.Bool Function(py_Ref, ffi.Pointer<ffi.Char>,
  2302. py_Ref)>>('py_dict_setitem_by_str');
  2303. late final _py_dict_setitem_by_str = _py_dict_setitem_by_strPtr
  2304. .asFunction<bool Function(py_Ref, ffi.Pointer<ffi.Char>, py_Ref)>();
  2305. /// true: success, false: error
  2306. bool py_dict_setitem_by_int(
  2307. py_Ref self,
  2308. int key,
  2309. py_Ref val,
  2310. ) {
  2311. return _py_dict_setitem_by_int(
  2312. self,
  2313. key,
  2314. val,
  2315. );
  2316. }
  2317. late final _py_dict_setitem_by_intPtr =
  2318. _lookup<ffi.NativeFunction<ffi.Bool Function(py_Ref, py_i64, py_Ref)>>(
  2319. 'py_dict_setitem_by_int');
  2320. late final _py_dict_setitem_by_int = _py_dict_setitem_by_intPtr
  2321. .asFunction<bool Function(py_Ref, int, py_Ref)>();
  2322. /// -1: error, 0: not found, 1: found (and deleted)
  2323. int py_dict_delitem_by_str(
  2324. py_Ref self,
  2325. ffi.Pointer<ffi.Char> key,
  2326. ) {
  2327. return _py_dict_delitem_by_str(
  2328. self,
  2329. key,
  2330. );
  2331. }
  2332. late final _py_dict_delitem_by_strPtr = _lookup<
  2333. ffi.NativeFunction<ffi.Int Function(py_Ref, ffi.Pointer<ffi.Char>)>>(
  2334. 'py_dict_delitem_by_str');
  2335. late final _py_dict_delitem_by_str = _py_dict_delitem_by_strPtr
  2336. .asFunction<int Function(py_Ref, ffi.Pointer<ffi.Char>)>();
  2337. /// -1: error, 0: not found, 1: found (and deleted)
  2338. int py_dict_delitem_by_int(
  2339. py_Ref self,
  2340. int key,
  2341. ) {
  2342. return _py_dict_delitem_by_int(
  2343. self,
  2344. key,
  2345. );
  2346. }
  2347. late final _py_dict_delitem_by_intPtr =
  2348. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref, py_i64)>>(
  2349. 'py_dict_delitem_by_int');
  2350. late final _py_dict_delitem_by_int =
  2351. _py_dict_delitem_by_intPtr.asFunction<int Function(py_Ref, int)>();
  2352. /// true: success, false: error
  2353. bool py_dict_apply(
  2354. py_Ref self,
  2355. ffi.Pointer<
  2356. ffi.NativeFunction<
  2357. ffi.Bool Function(
  2358. py_Ref key, py_Ref val, ffi.Pointer<ffi.Void> ctx)>>
  2359. f,
  2360. ffi.Pointer<ffi.Void> ctx,
  2361. ) {
  2362. return _py_dict_apply(
  2363. self,
  2364. f,
  2365. ctx,
  2366. );
  2367. }
  2368. late final _py_dict_applyPtr = _lookup<
  2369. ffi.NativeFunction<
  2370. ffi.Bool Function(
  2371. py_Ref,
  2372. ffi.Pointer<
  2373. ffi.NativeFunction<
  2374. ffi.Bool Function(
  2375. py_Ref key, py_Ref val, ffi.Pointer<ffi.Void> ctx)>>,
  2376. ffi.Pointer<ffi.Void>)>>('py_dict_apply');
  2377. late final _py_dict_apply = _py_dict_applyPtr.asFunction<
  2378. bool Function(
  2379. py_Ref,
  2380. ffi.Pointer<
  2381. ffi.NativeFunction<
  2382. ffi.Bool Function(
  2383. py_Ref key, py_Ref val, ffi.Pointer<ffi.Void> ctx)>>,
  2384. ffi.Pointer<ffi.Void>)>();
  2385. /// noexcept
  2386. int py_dict_len(
  2387. py_Ref self,
  2388. ) {
  2389. return _py_dict_len(
  2390. self,
  2391. );
  2392. }
  2393. late final _py_dict_lenPtr =
  2394. _lookup<ffi.NativeFunction<ffi.Int Function(py_Ref)>>('py_dict_len');
  2395. late final _py_dict_len = _py_dict_lenPtr.asFunction<int Function(py_Ref)>();
  2396. /// linalg module
  2397. void py_newvec2(
  2398. py_OutRef out,
  2399. c11_vec2 arg1,
  2400. ) {
  2401. return _py_newvec2(
  2402. out,
  2403. arg1,
  2404. );
  2405. }
  2406. late final _py_newvec2Ptr =
  2407. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, c11_vec2)>>(
  2408. 'py_newvec2');
  2409. late final _py_newvec2 =
  2410. _py_newvec2Ptr.asFunction<void Function(py_OutRef, c11_vec2)>();
  2411. void py_newvec3(
  2412. py_OutRef out,
  2413. c11_vec3 arg1,
  2414. ) {
  2415. return _py_newvec3(
  2416. out,
  2417. arg1,
  2418. );
  2419. }
  2420. late final _py_newvec3Ptr =
  2421. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, c11_vec3)>>(
  2422. 'py_newvec3');
  2423. late final _py_newvec3 =
  2424. _py_newvec3Ptr.asFunction<void Function(py_OutRef, c11_vec3)>();
  2425. void py_newvec2i(
  2426. py_OutRef out,
  2427. c11_vec2i arg1,
  2428. ) {
  2429. return _py_newvec2i(
  2430. out,
  2431. arg1,
  2432. );
  2433. }
  2434. late final _py_newvec2iPtr =
  2435. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, c11_vec2i)>>(
  2436. 'py_newvec2i');
  2437. late final _py_newvec2i =
  2438. _py_newvec2iPtr.asFunction<void Function(py_OutRef, c11_vec2i)>();
  2439. void py_newvec3i(
  2440. py_OutRef out,
  2441. c11_vec3i arg1,
  2442. ) {
  2443. return _py_newvec3i(
  2444. out,
  2445. arg1,
  2446. );
  2447. }
  2448. late final _py_newvec3iPtr =
  2449. _lookup<ffi.NativeFunction<ffi.Void Function(py_OutRef, c11_vec3i)>>(
  2450. 'py_newvec3i');
  2451. late final _py_newvec3i =
  2452. _py_newvec3iPtr.asFunction<void Function(py_OutRef, c11_vec3i)>();
  2453. ffi.Pointer<c11_mat3x3> py_newmat3x3(
  2454. py_OutRef out,
  2455. ) {
  2456. return _py_newmat3x3(
  2457. out,
  2458. );
  2459. }
  2460. late final _py_newmat3x3Ptr =
  2461. _lookup<ffi.NativeFunction<ffi.Pointer<c11_mat3x3> Function(py_OutRef)>>(
  2462. 'py_newmat3x3');
  2463. late final _py_newmat3x3 = _py_newmat3x3Ptr
  2464. .asFunction<ffi.Pointer<c11_mat3x3> Function(py_OutRef)>();
  2465. c11_vec2 py_tovec2(
  2466. py_Ref self,
  2467. ) {
  2468. return _py_tovec2(
  2469. self,
  2470. );
  2471. }
  2472. late final _py_tovec2Ptr =
  2473. _lookup<ffi.NativeFunction<c11_vec2 Function(py_Ref)>>('py_tovec2');
  2474. late final _py_tovec2 = _py_tovec2Ptr.asFunction<c11_vec2 Function(py_Ref)>();
  2475. c11_vec3 py_tovec3(
  2476. py_Ref self,
  2477. ) {
  2478. return _py_tovec3(
  2479. self,
  2480. );
  2481. }
  2482. late final _py_tovec3Ptr =
  2483. _lookup<ffi.NativeFunction<c11_vec3 Function(py_Ref)>>('py_tovec3');
  2484. late final _py_tovec3 = _py_tovec3Ptr.asFunction<c11_vec3 Function(py_Ref)>();
  2485. c11_vec2i py_tovec2i(
  2486. py_Ref self,
  2487. ) {
  2488. return _py_tovec2i(
  2489. self,
  2490. );
  2491. }
  2492. late final _py_tovec2iPtr =
  2493. _lookup<ffi.NativeFunction<c11_vec2i Function(py_Ref)>>('py_tovec2i');
  2494. late final _py_tovec2i =
  2495. _py_tovec2iPtr.asFunction<c11_vec2i Function(py_Ref)>();
  2496. c11_vec3i py_tovec3i(
  2497. py_Ref self,
  2498. ) {
  2499. return _py_tovec3i(
  2500. self,
  2501. );
  2502. }
  2503. late final _py_tovec3iPtr =
  2504. _lookup<ffi.NativeFunction<c11_vec3i Function(py_Ref)>>('py_tovec3i');
  2505. late final _py_tovec3i =
  2506. _py_tovec3iPtr.asFunction<c11_vec3i Function(py_Ref)>();
  2507. ffi.Pointer<c11_mat3x3> py_tomat3x3(
  2508. py_Ref self,
  2509. ) {
  2510. return _py_tomat3x3(
  2511. self,
  2512. );
  2513. }
  2514. late final _py_tomat3x3Ptr =
  2515. _lookup<ffi.NativeFunction<ffi.Pointer<c11_mat3x3> Function(py_Ref)>>(
  2516. 'py_tomat3x3');
  2517. late final _py_tomat3x3 =
  2518. _py_tomat3x3Ptr.asFunction<ffi.Pointer<c11_mat3x3> Function(py_Ref)>();
  2519. /// An utility function to read a line from stdin for REPL.
  2520. int py_replinput(
  2521. ffi.Pointer<ffi.Char> buf,
  2522. int max_size,
  2523. ) {
  2524. return _py_replinput(
  2525. buf,
  2526. max_size,
  2527. );
  2528. }
  2529. late final _py_replinputPtr = _lookup<
  2530. ffi.NativeFunction<ffi.Int Function(ffi.Pointer<ffi.Char>, ffi.Int)>>(
  2531. 'py_replinput');
  2532. late final _py_replinput =
  2533. _py_replinputPtr.asFunction<int Function(ffi.Pointer<ffi.Char>, int)>();
  2534. }
  2535. final class c11_vec2i extends ffi.Union {
  2536. external UnnamedStruct1 unnamed;
  2537. @ffi.Array.multi([2])
  2538. external ffi.Array<ffi.Int> data;
  2539. @ffi.Int64()
  2540. external int _i64;
  2541. }
  2542. final class UnnamedStruct1 extends ffi.Struct {
  2543. @ffi.Int()
  2544. external int x;
  2545. @ffi.Int()
  2546. external int y;
  2547. }
  2548. final class c11_vec3i extends ffi.Union {
  2549. external UnnamedStruct2 unnamed;
  2550. @ffi.Array.multi([3])
  2551. external ffi.Array<ffi.Int> data;
  2552. }
  2553. final class UnnamedStruct2 extends ffi.Struct {
  2554. @ffi.Int()
  2555. external int x;
  2556. @ffi.Int()
  2557. external int y;
  2558. @ffi.Int()
  2559. external int z;
  2560. }
  2561. final class c11_vec2 extends ffi.Union {
  2562. external UnnamedStruct3 unnamed;
  2563. @ffi.Array.multi([2])
  2564. external ffi.Array<ffi.Float> data;
  2565. }
  2566. final class UnnamedStruct3 extends ffi.Struct {
  2567. @ffi.Float()
  2568. external double x;
  2569. @ffi.Float()
  2570. external double y;
  2571. }
  2572. final class c11_vec3 extends ffi.Union {
  2573. external UnnamedStruct4 unnamed;
  2574. @ffi.Array.multi([3])
  2575. external ffi.Array<ffi.Float> data;
  2576. }
  2577. final class UnnamedStruct4 extends ffi.Struct {
  2578. @ffi.Float()
  2579. external double x;
  2580. @ffi.Float()
  2581. external double y;
  2582. @ffi.Float()
  2583. external double z;
  2584. }
  2585. final class c11_mat3x3 extends ffi.Union {
  2586. external UnnamedStruct5 unnamed;
  2587. @ffi.Array.multi([3, 3])
  2588. external ffi.Array<ffi.Array<ffi.Float>> m;
  2589. @ffi.Array.multi([9])
  2590. external ffi.Array<ffi.Float> data;
  2591. }
  2592. final class UnnamedStruct5 extends ffi.Struct {
  2593. @ffi.Float()
  2594. external double _11;
  2595. @ffi.Float()
  2596. external double _12;
  2597. @ffi.Float()
  2598. external double _13;
  2599. @ffi.Float()
  2600. external double _21;
  2601. @ffi.Float()
  2602. external double _22;
  2603. @ffi.Float()
  2604. external double _23;
  2605. @ffi.Float()
  2606. external double _31;
  2607. @ffi.Float()
  2608. external double _32;
  2609. @ffi.Float()
  2610. external double _33;
  2611. }
  2612. final class py_TValue extends ffi.Opaque {}
  2613. /// A string view type. It is helpful for passing strings which are not null-terminated.
  2614. final class c11_sv extends ffi.Struct {
  2615. external ffi.Pointer<ffi.Char> data;
  2616. @ffi.Int()
  2617. external int size;
  2618. }
  2619. /// A struct contains the callbacks of the VM.
  2620. final class py_Callbacks extends ffi.Struct {
  2621. /// Used by `__import__` to load source code of a module.
  2622. external ffi.Pointer<
  2623. ffi.NativeFunction<
  2624. ffi.Pointer<ffi.Char> Function(ffi.Pointer<ffi.Char>)>> importfile;
  2625. /// Used by `print` to output a string.
  2626. external ffi
  2627. .Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Char>)>>
  2628. print;
  2629. /// Used by `input` to get a character.
  2630. external ffi.Pointer<ffi.NativeFunction<ffi.Int Function()>> getchar;
  2631. }
  2632. /// Python compiler modes.
  2633. /// + `EXEC_MODE`: for statements.
  2634. /// + `EVAL_MODE`: for expressions.
  2635. /// + `SINGLE_MODE`: for REPL or jupyter notebook execution.
  2636. abstract class py_CompileMode {
  2637. static const int EXEC_MODE = 0;
  2638. static const int EVAL_MODE = 1;
  2639. static const int SINGLE_MODE = 2;
  2640. }
  2641. /// A generic reference to a python object.
  2642. typedef py_Ref = ffi.Pointer<py_TValue>;
  2643. /// An output reference for returning a value.
  2644. typedef py_OutRef = ffi.Pointer<py_TValue>;
  2645. /// A global reference which has the same lifespan as the VM.
  2646. typedef py_GlobalRef = ffi.Pointer<py_TValue>;
  2647. /// A 64-bit integer type. Corresponds to `int` in python.
  2648. typedef py_i64 = ffi.Int64;
  2649. /// A 64-bit floating-point type. Corresponds to `float` in python.
  2650. typedef py_f64 = ffi.Double;
  2651. /// A reference which has the same lifespan as the python object.
  2652. typedef py_ObjectRef = ffi.Pointer<py_TValue>;
  2653. /// Native function signature.
  2654. /// @param argc number of arguments.
  2655. /// @param argv array of arguments. Use `py_arg(i)` macro to get the i-th argument.
  2656. /// @return `true` if the function is successful or `false` if an exception is raised.
  2657. typedef py_CFunction = ffi.Pointer<
  2658. ffi.NativeFunction<ffi.Bool Function(ffi.Int argc, py_StackRef argv)>>;
  2659. /// A specific location in the value stack of the VM.
  2660. typedef py_StackRef = ffi.Pointer<py_TValue>;
  2661. /// An integer that represents a python identifier. This is to achieve string pooling and fast name
  2662. /// resolution.
  2663. typedef py_Name = ffi.Uint16;
  2664. /// An integer that represents a python type. `0` is invalid.
  2665. typedef py_Type = ffi.Int16;
  2666. /// A generic destructor function.
  2667. typedef py_Dtor
  2668. = ffi.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>;
  2669. /// An item reference to a container object. It invalidates when the container is modified.
  2670. typedef py_ItemRef = ffi.Pointer<py_TValue>;
  2671. /// Python favored string formatting.
  2672. /// %d: int
  2673. /// %i: py_i64 (int64_t)
  2674. /// %f: py_f64 (double)
  2675. /// %s: const char*
  2676. /// %q: c11_sv
  2677. /// %v: c11_sv
  2678. /// %c: char
  2679. /// %p: void*
  2680. /// %t: py_Type
  2681. /// %n: py_Name
  2682. abstract class py_MagicNames {
  2683. /// 0 is reserved
  2684. static const int py_MagicNames__NULL = 0;
  2685. /// math operators
  2686. static const int __lt__ = 1;
  2687. static const int __le__ = 2;
  2688. static const int __gt__ = 3;
  2689. static const int __ge__ = 4;
  2690. /// //////////////////////////
  2691. static const int __neg__ = 5;
  2692. static const int __abs__ = 6;
  2693. static const int __float__ = 7;
  2694. static const int __int__ = 8;
  2695. static const int __round__ = 9;
  2696. static const int __divmod__ = 10;
  2697. /// //////////////////////////
  2698. static const int __add__ = 11;
  2699. static const int __radd__ = 12;
  2700. static const int __sub__ = 13;
  2701. static const int __rsub__ = 14;
  2702. static const int __mul__ = 15;
  2703. static const int __rmul__ = 16;
  2704. static const int __truediv__ = 17;
  2705. static const int __rtruediv__ = 18;
  2706. static const int __floordiv__ = 19;
  2707. static const int __rfloordiv__ = 20;
  2708. static const int __mod__ = 21;
  2709. static const int __rmod__ = 22;
  2710. static const int __pow__ = 23;
  2711. static const int __rpow__ = 24;
  2712. static const int __matmul__ = 25;
  2713. static const int __lshift__ = 26;
  2714. static const int __rshift__ = 27;
  2715. static const int __and__ = 28;
  2716. static const int __or__ = 29;
  2717. static const int __xor__ = 30;
  2718. /// //////////////////////////
  2719. static const int __repr__ = 31;
  2720. static const int __str__ = 32;
  2721. static const int __hash__ = 33;
  2722. static const int __len__ = 34;
  2723. static const int __iter__ = 35;
  2724. static const int __next__ = 36;
  2725. static const int __contains__ = 37;
  2726. static const int __bool__ = 38;
  2727. static const int __invert__ = 39;
  2728. /// //////////////////////////
  2729. static const int __eq__ = 40;
  2730. static const int __ne__ = 41;
  2731. /// indexer
  2732. static const int __getitem__ = 42;
  2733. static const int __setitem__ = 43;
  2734. static const int __delitem__ = 44;
  2735. /// specials
  2736. static const int __new__ = 45;
  2737. static const int __init__ = 46;
  2738. static const int __call__ = 47;
  2739. static const int __enter__ = 48;
  2740. static const int __exit__ = 49;
  2741. static const int __name__ = 50;
  2742. static const int __all__ = 51;
  2743. static const int __package__ = 52;
  2744. static const int __path__ = 53;
  2745. static const int __class__ = 54;
  2746. static const int __getattr__ = 55;
  2747. static const int __reduce__ = 56;
  2748. static const int __missing__ = 57;
  2749. }
  2750. abstract class py_PredefinedTypes {
  2751. static const int tp_nil = 0;
  2752. static const int tp_object = 1;
  2753. /// py_Type
  2754. static const int tp_type = 2;
  2755. static const int tp_int = 3;
  2756. static const int tp_float = 4;
  2757. static const int tp_bool = 5;
  2758. static const int tp_str = 6;
  2759. static const int tp_str_iterator = 7;
  2760. /// c11_vector
  2761. static const int tp_list = 8;
  2762. /// N slots
  2763. static const int tp_tuple = 9;
  2764. static const int tp_array_iterator = 10;
  2765. /// 3 slots (start, stop, step)
  2766. static const int tp_slice = 11;
  2767. static const int tp_range = 12;
  2768. static const int tp_range_iterator = 13;
  2769. static const int tp_module = 14;
  2770. static const int tp_function = 15;
  2771. static const int tp_nativefunc = 16;
  2772. /// 2 slots (self, func)
  2773. static const int tp_boundmethod = 17;
  2774. /// 1 slot + py_Type
  2775. static const int tp_super = 18;
  2776. /// 2 slots (arg + inner_exc)
  2777. static const int tp_BaseException = 19;
  2778. static const int tp_Exception = 20;
  2779. static const int tp_bytes = 21;
  2780. static const int tp_namedict = 22;
  2781. static const int tp_locals = 23;
  2782. static const int tp_code = 24;
  2783. static const int tp_dict = 25;
  2784. /// 1 slot
  2785. static const int tp_dict_items = 26;
  2786. /// 2 slots (getter + setter)
  2787. static const int tp_property = 27;
  2788. /// 1 slot + int level
  2789. static const int tp_star_wrapper = 28;
  2790. /// 1 slot
  2791. static const int tp_staticmethod = 29;
  2792. /// 1 slot
  2793. static const int tp_classmethod = 30;
  2794. static const int tp_NoneType = 31;
  2795. static const int tp_NotImplementedType = 32;
  2796. static const int tp_ellipsis = 33;
  2797. static const int tp_generator = 34;
  2798. /// builtin exceptions
  2799. static const int tp_SystemExit = 35;
  2800. static const int tp_KeyboardInterrupt = 36;
  2801. static const int tp_StopIteration = 37;
  2802. static const int tp_SyntaxError = 38;
  2803. static const int tp_StackOverflowError = 39;
  2804. static const int tp_OSError = 40;
  2805. static const int tp_NotImplementedError = 41;
  2806. static const int tp_TypeError = 42;
  2807. static const int tp_IndexError = 43;
  2808. static const int tp_ValueError = 44;
  2809. static const int tp_RuntimeError = 45;
  2810. static const int tp_ZeroDivisionError = 46;
  2811. static const int tp_NameError = 47;
  2812. static const int tp_UnboundLocalError = 48;
  2813. static const int tp_AttributeError = 49;
  2814. static const int tp_ImportError = 50;
  2815. static const int tp_AssertionError = 51;
  2816. static const int tp_KeyError = 52;
  2817. /// linalg
  2818. static const int tp_vec2 = 53;
  2819. static const int tp_vec3 = 54;
  2820. static const int tp_vec2i = 55;
  2821. static const int tp_vec3i = 56;
  2822. static const int tp_mat3x3 = 57;
  2823. /// array2d
  2824. static const int tp_array2d_like = 58;
  2825. static const int tp_array2d_like_iterator = 59;
  2826. static const int tp_array2d = 60;
  2827. static const int tp_array2d_view = 61;
  2828. static const int tp_chunked_array2d = 62;
  2829. }
  2830. const String PK_VERSION = '2.0.6';
  2831. const int PK_VERSION_MAJOR = 2;
  2832. const int PK_VERSION_MINOR = 0;
  2833. const int PK_VERSION_PATCH = 6;
  2834. const int PK_LOW_MEMORY_MODE = 0;
  2835. const int PK_ENABLE_OS = 1;
  2836. const int PK_GC_MIN_THRESHOLD = 16384;
  2837. const int PK_VM_STACK_SIZE = 16384;
  2838. const int PK_MAX_CO_VARNAMES = 64;
  2839. const int PK_MAX_MODULE_PATH_LEN = 63;
  2840. const double PK_M_PI = 3.141592653589793;
  2841. const double PK_M_E = 2.718281828459045;
  2842. const double PK_M_DEG2RAD = 0.017453292519943295;
  2843. const double PK_M_RAD2DEG = 57.29577951308232;
  2844. const int PK_PLATFORM_SEP = 47;
  2845. const int PY_SYS_PLATFORM = 3;
  2846. const String PY_SYS_PLATFORM_STRING = 'darwin';
  2847. const int PK_IS_DESKTOP_PLATFORM = 1;