#pragma once
#define PK_IS_PUBLIC_INCLUDE
#define PK_VERSION "2.1.8"
#define PK_VERSION_MAJOR 2
#define PK_VERSION_MINOR 1
#define PK_VERSION_PATCH 8
#ifndef PK_ENABLE_OS
#define PK_ENABLE_OS 1
#endif
#ifndef PK_ENABLE_THREADS
#define PK_ENABLE_THREADS 1
#endif
#ifndef PK_ENABLE_DETERMINISM
#define PK_ENABLE_DETERMINISM 0
#endif
#ifndef PK_ENABLE_WATCHDOG
#define PK_ENABLE_WATCHDOG 0
#endif
#ifndef PK_ENABLE_CUSTOM_SNAME
#define PK_ENABLE_CUSTOM_SNAME 0
#endif
#ifndef PK_ENABLE_MIMALLOC
#define PK_ENABLE_MIMALLOC 0
#endif
#ifndef PK_GC_MIN_THRESHOLD
#define PK_GC_MIN_THRESHOLD 20000
#endif
#ifndef PK_VM_STACK_SIZE
#define PK_VM_STACK_SIZE 16384
#endif
#ifndef PK_MAX_CO_VARNAMES
#define PK_MAX_CO_VARNAMES 64
#endif
#define PK_MAX_MODULE_PATH_LEN 63
#define PK_INST_ATTR_LOAD_FACTOR 0.67f
#define PK_TYPE_ATTR_LOAD_FACTOR 0.5f
#ifdef _WIN32
#define PK_PLATFORM_SEP '\\'
#else
#define PK_PLATFORM_SEP '/'
#endif
#ifdef __cplusplus
#ifndef restrict
#define restrict
#endif
#endif
#if PK_ENABLE_THREADS
#define PK_THREAD_LOCAL _Thread_local
#else
#define PK_THREAD_LOCAL
#endif
#ifndef PK_MALLOC
#if PK_ENABLE_MIMALLOC
#include "mimalloc.h"
#define PK_MALLOC(size) mi_malloc(size)
#define PK_REALLOC(ptr, size) mi_realloc(ptr, size)
#define PK_FREE(ptr) mi_free(ptr)
#else
#ifndef __cplusplus
#include <stdlib.h>
#define PK_MALLOC(size) malloc(size)
#define PK_REALLOC(ptr, size) realloc(ptr, size)
#define PK_FREE(ptr) free(ptr)
#else
#include <cstdlib>
#define PK_MALLOC(size) std::malloc(size)
#define PK_REALLOC(ptr, size) std::realloc(ptr, size)
#define PK_FREE(ptr) std::free(ptr)
#endif
#endif
#endif
#if defined(_WIN32) || defined(_WIN64)
#ifdef PY_DYNAMIC_MODULE
#define PK_API __declspec(dllimport)
#else
#define PK_API __declspec(dllexport)
#endif
#define PK_EXPORT __declspec(dllexport)
#define PY_SYS_PLATFORM 0
#define PY_SYS_PLATFORM_STRING "win32"
#elif __EMSCRIPTEN__
#define PK_API
#define PK_EXPORT
#define PY_SYS_PLATFORM 1
#define PY_SYS_PLATFORM_STRING "emscripten"
#elif __APPLE__
#include <TargetConditionals.h>
#if TARGET_IPHONE_SIMULATOR
#define PY_SYS_PLATFORM 2
#define PY_SYS_PLATFORM_STRING "ios"
#elif TARGET_OS_IPHONE
#define PY_SYS_PLATFORM 2
#define PY_SYS_PLATFORM_STRING "ios"
#elif TARGET_OS_MAC
#define PY_SYS_PLATFORM 3
#define PY_SYS_PLATFORM_STRING "darwin"
#else
# error "Unknown Apple platform"
#endif
#define PK_API __attribute__((visibility("default")))
#define PK_EXPORT __attribute__((visibility("default")))
#elif __ANDROID__
#define PK_API __attribute__((visibility("default")))
#define PK_EXPORT __attribute__((visibility("default")))
#define PY_SYS_PLATFORM 4
#define PY_SYS_PLATFORM_STRING "android"
#elif __linux__
#define PK_API __attribute__((visibility("default")))
#define PK_EXPORT __attribute__((visibility("default")))
#define PY_SYS_PLATFORM 5
#define PY_SYS_PLATFORM_STRING "linux"
#else
#define PK_API
#define PY_SYS_PLATFORM 6
#define PY_SYS_PLATFORM_STRING "unknown"
#endif
#if PY_SYS_PLATFORM == 0 || PY_SYS_PLATFORM == 3 || PY_SYS_PLATFORM == 5
#define PK_IS_DESKTOP_PLATFORM 1
#else
#define PK_IS_DESKTOP_PLATFORM 0
#endif
#if defined(__GNUC__) || defined(__clang__)
#define PK_DEPRECATED __attribute__((deprecated))
#else
#define PK_DEPRECATED
#endif
#ifdef NDEBUG
#if defined(__GNUC__)
#define PK_INLINE __attribute__((always_inline)) inline
#elif defined(_MSC_VER) && !defined(__clang__)
#define PK_INLINE __forceinline
#else
#define PK_INLINE inline
#endif
#else
#define PK_INLINE
#endif
#include <stdint.h>
typedef union c11_vec2i {
struct { int x, y; };
int data[2];
int64_t _i64;
} c11_vec2i;
typedef union c11_vec3i {
struct { int x, y, z; };
int data[3];
} c11_vec3i;
typedef union c11_vec4i {
struct { int x, y, z, w; };
int data[4];
} c11_vec4i;
typedef union c11_vec2 {
struct { float x, y; };
float data[2];
} c11_vec2;
typedef union c11_vec3 {
struct { float x, y, z; };
float data[3];
} c11_vec3;
typedef union c11_mat3x3 {
struct {
float _11, _12, _13;
float _21, _22, _23;
float _31, _32, _33;
};
float m[3][3];
float data[9];
} c11_mat3x3;
typedef union c11_color32 {
struct {
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
};
unsigned char data[4];
uint32_t u32;
} c11_color32;
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct py_OpaqueName py_OpaqueName;
typedef py_OpaqueName* py_Name;
typedef struct py_TValue py_TValue;
typedef int16_t py_Type;
typedef int64_t py_i64;
typedef double py_f64;
typedef void (*py_Dtor)(void*);
typedef struct c11_sv {
const char* data;
int size;
} c11_sv;
#define PY_RAISE
#define PY_RETURN
#define PY_MAYBENULL
typedef py_TValue* py_Ref;
typedef py_TValue* py_ObjectRef;
typedef py_TValue* py_GlobalRef;
typedef py_TValue* py_StackRef;
typedef py_TValue* py_ItemRef;
typedef py_TValue* py_OutRef;
typedef struct py_Frame py_Frame;
enum py_TraceEvent {
TRACE_EVENT_LINE,
TRACE_EVENT_PUSH,
TRACE_EVENT_POP,
};
typedef void (*py_TraceFunc)(py_Frame* frame, enum py_TraceEvent);
typedef struct py_Callbacks {
char* (*importfile)(const char* path, int* data_size);
PY_MAYBENULL py_GlobalRef (*lazyimport)(const char*);
void (*print)(const char*);
void (*flush)();
int (*getchr)();
PY_MAYBENULL void (*gc_mark)(void (*f)(py_Ref val, void* ctx), void* ctx);
PY_MAYBENULL bool (*displayhook)(py_Ref val) PY_RAISE;
} py_Callbacks;
typedef struct py_AppCallbacks {
void (*on_vm_ctor)(int index);
void (*on_vm_dtor)(int index);
} py_AppCallbacks;
typedef bool (*py_CFunction)(int argc, py_StackRef argv) PY_RAISE PY_RETURN;
enum py_CompileMode { EXEC_MODE, EVAL_MODE, SINGLE_MODE, RELOAD_MODE };
PK_API void py_initialize();
PK_API void py_finalize();
PK_API int py_currentvm();
PK_API void py_switchvm(int index);
PK_API void py_resetvm();
PK_API void py_resetallvm();
PK_API void* py_getvmctx();
PK_API void py_setvmctx(void* ctx);
PK_API py_Callbacks* py_callbacks();
PK_API py_AppCallbacks* py_appcallbacks();
PK_API void py_sys_setargv(int argc, char** argv);
PK_API void py_sys_settrace(py_TraceFunc func, bool reset);
PK_API int py_gc_collect();
PK_API void* py_malloc(size_t size);
PK_API void* py_realloc(void* ptr, size_t size);
PK_API void py_free(void* ptr);
PK_API py_GlobalRef py_True();
PK_API py_GlobalRef py_False();
PK_API py_GlobalRef py_None();
PK_API py_GlobalRef py_NIL();
PK_API const char* py_Frame_sourceloc(py_Frame* frame, int* lineno);
PK_API void py_Frame_newglobals(py_Frame* frame, py_OutRef out);
PK_API void py_Frame_newlocals(py_Frame* frame, py_OutRef out);
PK_API py_StackRef py_Frame_function(py_Frame* frame);
PK_API bool py_compile(const char* source,
const char* filename,
enum py_CompileMode mode,
bool is_dynamic) PY_RAISE PY_RETURN;
PK_API bool py_compilefile(const char* src_path,
const char* dst_path) PY_RAISE;
PK_API bool py_execo(const void* data, int size, const char* filename, py_Ref module) PY_RAISE PY_RETURN;
PK_API bool py_exec(const char* source,
const char* filename,
enum py_CompileMode mode,
py_Ref module) PY_RAISE PY_RETURN;
PK_API bool py_eval(const char* source, py_Ref module) PY_RAISE PY_RETURN;
PK_API bool py_smartexec(const char* source, py_Ref module, ...) PY_RAISE PY_RETURN;
PK_API bool py_smarteval(const char* source, py_Ref module, ...) PY_RAISE PY_RETURN;
PK_API void py_newint(py_OutRef, py_i64);
PK_API void py_newtrivial(py_OutRef out, py_Type type, void* data, int size);
PK_API void py_newfloat(py_OutRef, py_f64);
PK_API void py_newbool(py_OutRef, bool);
PK_API void py_newstr(py_OutRef, const char*);
PK_API char* py_newstrn(py_OutRef, int);
PK_API void py_newstrv(py_OutRef, c11_sv);
PK_API void py_newfstr(py_OutRef, const char*, ...);
PK_API unsigned char* py_newbytes(py_OutRef, int n);
PK_API void py_newnone(py_OutRef);
PK_API void py_newnotimplemented(py_OutRef);
PK_API void py_newellipsis(py_OutRef);
PK_API void py_newnil(py_OutRef);
PK_API void py_newnativefunc(py_OutRef, py_CFunction);
PK_API py_Name py_newfunction(py_OutRef out,
const char* sig,
py_CFunction f,
const char* docstring,
int slots);
PK_API void py_newboundmethod(py_OutRef out, py_Ref self, py_Ref func);
PK_API void* py_newobject(py_OutRef out, py_Type type, int slots, int udsize);
PK_API py_Name py_name(const char*);
PK_API const char* py_name2str(py_Name);
PK_API py_GlobalRef py_name2ref(py_Name);
PK_API py_Name py_namev(c11_sv);
PK_API c11_sv py_name2sv(py_Name);
PK_API void py_bind(py_Ref obj, const char* sig, py_CFunction f);
PK_API void py_bindmethod(py_Type type, const char* name, py_CFunction f);
PK_API void py_bindstaticmethod(py_Type type, const char* name, py_CFunction f);
PK_API void py_bindfunc(py_Ref obj, const char* name, py_CFunction f);
PK_API void
py_bindproperty(py_Type type, const char* name, py_CFunction getter, py_CFunction setter);
PK_API void py_bindmagic(py_Type type, py_Name name, py_CFunction f);
PK_API py_i64 py_toint(py_Ref);
PK_API void* py_totrivial(py_Ref);
PK_API py_f64 py_tofloat(py_Ref);
PK_API bool py_castfloat(py_Ref, py_f64* out) PY_RAISE;
PK_API bool py_castfloat32(py_Ref, float* out) PY_RAISE;
PK_API bool py_castint(py_Ref, py_i64* out) PY_RAISE;
PK_API bool py_tobool(py_Ref);
PK_API py_Type py_totype(py_Ref);
PK_API void* py_touserdata(py_Ref);
PK_API const char* py_tostr(py_Ref);
PK_API const char* py_tostrn(py_Ref, int* size);
PK_API c11_sv py_tosv(py_Ref);
PK_API unsigned char* py_tobytes(py_Ref, int* size);
PK_API void py_bytes_resize(py_Ref, int size);
PK_API py_Type py_newtype(const char* name, py_Type base, const py_GlobalRef module, py_Dtor dtor);
PK_API bool py_istype(py_Ref, py_Type);
PK_API py_Type py_typeof(py_Ref self);
PK_API bool py_isinstance(py_Ref obj, py_Type type);
PK_API bool py_issubclass(py_Type derived, py_Type base);
PK_API py_Type py_gettype(const char* module, py_Name name);
PK_API bool py_checktype(py_Ref self, py_Type type) PY_RAISE;
PK_API bool py_checkinstance(py_Ref self, py_Type type) PY_RAISE;
PK_API PK_DEPRECATED py_GlobalRef py_tpgetmagic(py_Type type, py_Name name);
PK_API py_GlobalRef py_tpfindmagic(py_Type, py_Name name);
PK_API py_ItemRef py_tpfindname(py_Type, py_Name name);
PK_API py_Type py_tpbase(py_Type type);
PK_API py_GlobalRef py_tpobject(py_Type type);
PK_API const char* py_tpname(py_Type type);
PK_API void py_tpsetfinal(py_Type type);
PK_API void py_tphookattributes(py_Type type,
bool (*getattribute)(py_Ref self, py_Name name) PY_RAISE PY_RETURN,
bool (*setattribute)(py_Ref self, py_Name name, py_Ref val)
PY_RAISE PY_RETURN,
bool (*delattribute)(py_Ref self, py_Name name) PY_RAISE,
bool (*getunboundmethod)(py_Ref self, py_Name name) PY_RETURN);
#define py_isint(self) py_istype(self, tp_int)
#define py_isfloat(self) py_istype(self, tp_float)
#define py_isbool(self) py_istype(self, tp_bool)
#define py_isstr(self) py_istype(self, tp_str)
#define py_islist(self) py_istype(self, tp_list)
#define py_istuple(self) py_istype(self, tp_tuple)
#define py_isdict(self) py_istype(self, tp_dict)
#define py_isnil(self) py_istype(self, 0)
#define py_isnone(self) py_istype(self, tp_NoneType)
#define py_checkint(self) py_checktype(self, tp_int)
#define py_checkfloat(self) py_checktype(self, tp_float)
#define py_checkbool(self) py_checktype(self, tp_bool)
#define py_checkstr(self) py_checktype(self, tp_str)
PK_API py_StackRef py_inspect_currentfunction();
PK_API py_GlobalRef py_inspect_currentmodule();
PK_API py_Frame* py_inspect_currentframe();
PK_API void py_newglobals(py_OutRef);
PK_API void py_newlocals(py_OutRef);
PK_API py_GlobalRef py_getreg(int i);
PK_API void py_setreg(int i, py_Ref val);
PK_API py_GlobalRef py_retval();
#define py_r0() py_getreg(0)
#define py_r1() py_getreg(1)
#define py_r2() py_getreg(2)
#define py_r3() py_getreg(3)
#define py_r4() py_getreg(4)
#define py_r5() py_getreg(5)
#define py_r6() py_getreg(6)
#define py_r7() py_getreg(7)
#define py_tmpr0() py_getreg(8)
#define py_tmpr1() py_getreg(9)
#define py_tmpr2() py_getreg(10)
#define py_tmpr3() py_getreg(11)
#define py_sysr0() py_getreg(12)
#define py_sysr1() py_getreg(13)
PK_API py_ItemRef py_getdict(py_Ref self, py_Name name);
PK_API void py_setdict(py_Ref self, py_Name name, py_Ref val);
PK_API bool py_deldict(py_Ref self, py_Name name);
PK_API py_ItemRef py_emplacedict(py_Ref self, py_Name name);
PK_API bool
py_applydict(py_Ref self, bool (*f)(py_Name name, py_Ref val, void* ctx), void* ctx) PY_RAISE;
PK_API void py_cleardict(py_Ref self);
PK_API py_ObjectRef py_getslot(py_Ref self, int i);
PK_API void py_setslot(py_Ref self, int i, py_Ref val);
PK_API py_ItemRef py_getbuiltin(py_Name name);
PK_API py_ItemRef py_getglobal(py_Name name);
PK_API void py_setglobal(py_Name name, py_Ref val);
PK_API py_StackRef py_peek(int i);
PK_API void py_push(py_Ref src);
PK_API void py_pushnil();
PK_API void py_pushnone();
PK_API void py_pushname(py_Name name);
PK_API void py_pop();
PK_API void py_shrink(int n);
PK_API py_StackRef py_pushtmp();
PK_API bool py_pushmethod(py_Name name);
PK_API bool py_pusheval(const char* expr, py_GlobalRef module) PY_RAISE;
PK_API bool py_vectorcall(uint16_t argc, uint16_t kwargc) PY_RAISE PY_RETURN;
PK_API bool py_call(py_Ref f, int argc, py_Ref argv) PY_RAISE PY_RETURN;
PK_API bool py_tpcall(py_Type type, int argc, py_Ref argv) PY_RAISE PY_RETURN;
#ifndef NDEBUG
PK_API bool py_callcfunc(py_CFunction f, int argc, py_Ref argv) PY_RAISE PY_RETURN;
#else
#define py_callcfunc(f, argc, argv) (f((argc), (argv)))
#endif
#define PY_CHECK_ARGC(n) \
if(argc != n) return TypeError("expected %d arguments, got %d", n, argc)
#define PY_CHECK_ARG_TYPE(i, type) \
if(!py_checktype(py_arg(i), type)) return false
#define py_offset(p, i) ((p) + (i))
#define py_arg(i) (&argv[i])
#define py_assign(dst, src) *(dst) = *(src)
PK_API bool py_binaryop(py_Ref lhs, py_Ref rhs, py_Name op, py_Name rop) PY_RAISE PY_RETURN;
PK_API bool py_binaryadd(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_binarysub(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_binarymul(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_binarytruediv(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_binaryfloordiv(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_binarymod(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_binarypow(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_binarylshift(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_binaryrshift(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_binaryand(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_binaryor(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_binaryxor(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_binarymatmul(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_eq(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_ne(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_lt(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_le(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_gt(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_ge(py_Ref lhs, py_Ref rhs) PY_RAISE PY_RETURN;
PK_API bool py_isidentical(py_Ref, py_Ref);
PK_API int py_bool(py_Ref val) PY_RAISE;
PK_API int py_equal(py_Ref lhs, py_Ref rhs) PY_RAISE;
PK_API int py_less(py_Ref lhs, py_Ref rhs) PY_RAISE;
PK_API bool py_callable(py_Ref val);
PK_API bool py_hash(py_Ref, py_i64* out) PY_RAISE;
PK_API bool py_iter(py_Ref) PY_RAISE PY_RETURN;
PK_API int py_next(py_Ref) PY_RAISE PY_RETURN;
PK_API bool py_str(py_Ref val) PY_RAISE PY_RETURN;
PK_API bool py_repr(py_Ref val) PY_RAISE PY_RETURN;
PK_API bool py_len(py_Ref val) PY_RAISE PY_RETURN;
PK_API bool py_getattr(py_Ref self, py_Name name) PY_RAISE PY_RETURN;
PK_API bool py_setattr(py_Ref self, py_Name name, py_Ref val) PY_RAISE;
PK_API bool py_delattr(py_Ref self, py_Name name) PY_RAISE;
PK_API bool py_getitem(py_Ref self, py_Ref key) PY_RAISE PY_RETURN;
PK_API bool py_setitem(py_Ref self, py_Ref key, py_Ref val) PY_RAISE;
PK_API bool py_delitem(py_Ref self, py_Ref key) PY_RAISE;
PK_API py_GlobalRef py_getmodule(const char* path);
PK_API py_GlobalRef py_newmodule(const char* path);
PK_API bool py_importlib_reload(py_Ref module) PY_RAISE PY_RETURN;
PK_API int py_import(const char* path) PY_RAISE PY_RETURN;
PK_API bool py_checkexc();
PK_API bool py_matchexc(py_Type type) PY_RETURN;
PK_API void py_clearexc(py_StackRef p0);
PK_API void py_printexc();
PK_API char* py_formatexc();
PK_API bool py_exception(py_Type type, const char* fmt, ...) PY_RAISE;
PK_API bool py_raise(py_Ref) PY_RAISE;
#define NameError(n) py_exception(tp_NameError, "name '%n' is not defined", (n))
#define TypeError(...) py_exception(tp_TypeError, __VA_ARGS__)
#define RuntimeError(...) py_exception(tp_RuntimeError, __VA_ARGS__)
#define TimeoutError(...) py_exception(tp_TimeoutError, __VA_ARGS__)
#define OSError(...) py_exception(tp_OSError, __VA_ARGS__)
#define ValueError(...) py_exception(tp_ValueError, __VA_ARGS__)
#define IndexError(...) py_exception(tp_IndexError, __VA_ARGS__)
#define ImportError(...) py_exception(tp_ImportError, __VA_ARGS__)
#define ZeroDivisionError(...) py_exception(tp_ZeroDivisionError, __VA_ARGS__)
#define AttributeError(self, n) \
py_exception(tp_AttributeError, "'%t' object has no attribute '%n'", (self)->type, (n))
#define UnboundLocalError(n) \
py_exception(tp_UnboundLocalError, \
"cannot access local variable '%n' where it is not associated with a value", \
(n))
PK_API bool KeyError(py_Ref key) PY_RAISE;
PK_API bool StopIteration() PY_RAISE;
#if PK_ENABLE_OS
PK_API void py_debugger_waitforattach(const char* hostname, unsigned short port);
PK_API int py_debugger_status();
PK_API void py_debugger_exceptionbreakpoint(py_Ref exc);
PK_API void py_debugger_exit(int code);
#else
#define py_debugger_waitforattach(hostname, port)
#define py_debugger_status() 0
#define py_debugger_exceptionbreakpoint(exc)
#define py_debugger_exit(code)
#endif
PK_API py_ObjectRef py_newtuple(py_OutRef, int n);
PK_API py_ObjectRef py_tuple_data(py_Ref self);
PK_API py_ObjectRef py_tuple_getitem(py_Ref self, int i);
PK_API void py_tuple_setitem(py_Ref self, int i, py_Ref val);
PK_API int py_tuple_len(py_Ref self);
PK_API void py_newlist(py_OutRef);
PK_API void py_newlistn(py_OutRef, int n);
PK_API py_ItemRef py_list_data(py_Ref self);
PK_API py_ItemRef py_list_getitem(py_Ref self, int i);
PK_API void py_list_setitem(py_Ref self, int i, py_Ref val);
PK_API void py_list_delitem(py_Ref self, int i);
PK_API int py_list_len(py_Ref self);
PK_API void py_list_swap(py_Ref self, int i, int j);
PK_API void py_list_append(py_Ref self, py_Ref val);
PK_API py_ItemRef py_list_emplace(py_Ref self);
PK_API void py_list_clear(py_Ref self);
PK_API void py_list_insert(py_Ref self, int i, py_Ref val);
PK_API void py_newdict(py_OutRef);
PK_API int py_dict_getitem(py_Ref self, py_Ref key) PY_RAISE PY_RETURN;
PK_API bool py_dict_setitem(py_Ref self, py_Ref key, py_Ref val) PY_RAISE;
PK_API int py_dict_delitem(py_Ref self, py_Ref key) PY_RAISE;
PK_API int py_dict_getitem_by_str(py_Ref self, const char* key) PY_RAISE PY_RETURN;
PK_API int py_dict_getitem_by_int(py_Ref self, py_i64 key) PY_RAISE PY_RETURN;
PK_API bool py_dict_setitem_by_str(py_Ref self, const char* key, py_Ref val) PY_RAISE;
PK_API bool py_dict_setitem_by_int(py_Ref self, py_i64 key, py_Ref val) PY_RAISE;
PK_API int py_dict_delitem_by_str(py_Ref self, const char* key) PY_RAISE;
PK_API int py_dict_delitem_by_int(py_Ref self, py_i64 key) PY_RAISE;
PK_API bool
py_dict_apply(py_Ref self, bool (*f)(py_Ref key, py_Ref val, void* ctx), void* ctx) PY_RAISE;
PK_API int py_dict_len(py_Ref self);
PK_API py_ObjectRef py_newslice(py_OutRef);
PK_API void py_newsliceint(py_OutRef out, py_i64 start, py_i64 stop, py_i64 step);
PK_API void py_newRandom(py_OutRef out);
PK_API void py_Random_seed(py_Ref self, py_i64 seed);
PK_API py_f64 py_Random_random(py_Ref self);
PK_API py_f64 py_Random_uniform(py_Ref self, py_f64 a, py_f64 b);
PK_API py_i64 py_Random_randint(py_Ref self, py_i64 a, py_i64 b);
PK_API void py_newarray2d(py_OutRef out, int width, int height);
PK_API int py_array2d_getwidth(py_Ref self);
PK_API int py_array2d_getheight(py_Ref self);
PK_API py_ObjectRef py_array2d_getitem(py_Ref self, int x, int y);
PK_API void py_array2d_setitem(py_Ref self, int x, int y, py_Ref val);
PK_API void py_newvec2(py_OutRef out, c11_vec2);
PK_API void py_newvec3(py_OutRef out, c11_vec3);
PK_API void py_newvec2i(py_OutRef out, c11_vec2i);
PK_API void py_newvec3i(py_OutRef out, c11_vec3i);
PK_API void py_newvec4i(py_OutRef out, c11_vec4i);
PK_API void py_newcolor32(py_OutRef out, c11_color32);
PK_API c11_mat3x3* py_newmat3x3(py_OutRef out);
PK_API c11_vec2 py_tovec2(py_Ref self);
PK_API c11_vec3 py_tovec3(py_Ref self);
PK_API c11_vec2i py_tovec2i(py_Ref self);
PK_API c11_vec3i py_tovec3i(py_Ref self);
PK_API c11_vec4i py_tovec4i(py_Ref self);
PK_API c11_mat3x3* py_tomat3x3(py_Ref self);
PK_API c11_color32 py_tocolor32(py_Ref self);
PK_API bool py_json_dumps(py_Ref val, int indent) PY_RAISE PY_RETURN;
PK_API bool py_json_loads(const char* source) PY_RAISE PY_RETURN;
PK_API bool py_pickle_dumps(py_Ref val) PY_RAISE PY_RETURN;
PK_API bool py_pickle_loads(const unsigned char* data, int size) PY_RAISE PY_RETURN;
PK_API void py_watchdog_begin(py_i64 timeout);
PK_API void py_watchdog_end();
PK_API void py_profiler_begin();
PK_API void py_profiler_end();
PK_API void py_profiler_reset();
PK_API char* py_profiler_report();
int64_t time_ns();
int64_t time_monotonic_ns();
PK_API int py_replinput(char* buf, int max_size);
enum py_PredefinedType {
tp_nil = 0,
tp_object = 1,
tp_type, tp_int,
tp_float,
tp_bool,
tp_str,
tp_str_iterator,
tp_list, tp_tuple, tp_list_iterator, tp_tuple_iterator, tp_slice, tp_range,
tp_range_iterator,
tp_module,
tp_function,
tp_nativefunc,
tp_boundmethod, tp_super, tp_BaseException,
tp_Exception,
tp_bytes,
tp_namedict,
tp_locals,
tp_code,
tp_dict,
tp_dict_iterator, tp_property, tp_star_wrapper, tp_staticmethod, tp_classmethod, tp_NoneType,
tp_NotImplementedType,
tp_ellipsis,
tp_generator,
tp_SystemExit,
tp_KeyboardInterrupt,
tp_StopIteration,
tp_SyntaxError,
tp_RecursionError,
tp_OSError,
tp_NotImplementedError,
tp_TypeError,
tp_IndexError,
tp_ValueError,
tp_RuntimeError,
tp_TimeoutError,
tp_ZeroDivisionError,
tp_NameError,
tp_UnboundLocalError,
tp_AttributeError,
tp_ImportError,
tp_AssertionError,
tp_KeyError,
tp_stdc_Memory,
tp_stdc_Char, tp_stdc_UChar,
tp_stdc_Short, tp_stdc_UShort,
tp_stdc_Int, tp_stdc_UInt,
tp_stdc_Long, tp_stdc_ULong,
tp_stdc_LongLong, tp_stdc_ULongLong,
tp_stdc_Float, tp_stdc_Double,
tp_stdc_Pointer,
tp_stdc_Bool,
tp_vec2,
tp_vec3,
tp_vec2i,
tp_vec3i,
tp_vec4i,
tp_mat3x3,
tp_color32,
tp_array2d_like,
tp_array2d_like_iterator,
tp_array2d,
tp_array2d_view,
tp_chunked_array2d,
};
#ifndef PK_IS_AMALGAMATED_C
#ifdef PK_IS_PUBLIC_INCLUDE
typedef struct py_TValue {
py_Type type;
bool is_ptr;
int extra;
union {
int64_t _i64;
double _f64;
bool _bool;
py_CFunction _cfunc;
void* _obj;
void* _ptr;
char _chars[16];
};
} py_TValue;
#endif
#endif
#ifdef __cplusplus
}
#endif