#ifndef PIXEL_SCRIPT_H
#define PIXEL_SCRIPT_H
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
typedef enum pxs_VarType {
pxs_Int64,
pxs_UInt64,
pxs_String,
pxs_Bool,
pxs_Float64,
pxs_Null,
pxs_Object,
pxs_HostObject,
pxs_List,
pxs_Function,
} pxs_VarType;
typedef enum pxs_Runtime {
pxs_Lua,
pxs_Python,
pxs_JavaScript,
pxs_Easyjs,
pxs_RustPython,
pxs_PHP,
} pxs_Runtime;
typedef struct pxs_Module pxs_Module;
typedef struct pxs_PixelObject pxs_PixelObject;
typedef struct pxs_VarList pxs_VarList;
typedef union pxs_VarValue {
int64_t i64_val;
uint64_t u64_val;
char *string_val;
bool bool_val;
double f64_val;
const void *null_val;
void *object_val;
int32_t host_object_val;
struct pxs_VarList *list_val;
void *function_val;
} pxs_VarValue;
typedef void (*pxs_DeleterFn)(void*);
typedef struct pxs_Var {
enum pxs_VarType tag;
union pxs_VarValue value;
pxs_DeleterFn deleter;
} pxs_Var;
typedef struct pxs_Var *(*pxs_Func)(struct pxs_Var *args, void *opaque);
typedef void *pxs_Opaque;
typedef void (*FreeMethod)(void *ptr);
typedef struct pxs_Var *pxs_VarT;
typedef char *(*LoadFileFn)(const char *file_path);
typedef void (*WriteFileFn)(const char *file_path, const char *contents);
typedef struct pxs_DirHandle {
uintptr_t length;
char **values;
} pxs_DirHandle;
typedef struct pxs_DirHandle (*ReadDirFn)(const char *dir_path);
#ifdef __cplusplus
extern "C" {
#endif
uint32_t pxs_version(void);
void pxs_initialize(void);
void pxs_finalize(void);
char *pxs_execlua(const char *code, const char *file_name);
char *pxs_execpython(const char *code,
const char *file_name);
void pxs_freestr(char *string);
struct pxs_Module *pxs_newmod(const char *name);
void pxs_addfunc(struct pxs_Module *module_ptr, const char *name, pxs_Func func, pxs_Opaque opaque);
void pxs_addvar(struct pxs_Module *module_ptr, const char *name, struct pxs_Var *variable);
void pxs_add_submod(struct pxs_Module *parent_ptr, struct pxs_Module *child_ptr);
void pxs_addmod(struct pxs_Module *module_ptr);
void pxs_freemod(struct pxs_Module *module_ptr);
struct pxs_PixelObject *pxs_newobject(pxs_Opaque ptr,
FreeMethod free_method,
const char *type_name);
void pxs_object_addfunc(struct pxs_PixelObject *object_ptr,
const char *name,
pxs_Func callback,
pxs_Opaque opaque);
void pxs_addobject(struct pxs_Module *module_ptr,
const char *name,
pxs_Func object_constructor,
pxs_Opaque opaque);
struct pxs_Var *pxs_newstring(const char *str);
struct pxs_Var *pxs_newnull(void);
struct pxs_Var *pxs_newhost(struct pxs_PixelObject *pixel_object);
struct pxs_Var *pxs_newint(int64_t val);
struct pxs_Var *pxs_newuint(uint64_t val);
struct pxs_Var *pxs_newbool(bool val);
struct pxs_Var *pxs_newfloat(double val);
struct pxs_Var *pxs_object_callrt(enum pxs_Runtime runtime,
struct pxs_Var *var,
const char *method,
struct pxs_Var *args);
pxs_VarT pxs_objectcall(struct pxs_Var *runtime,
struct pxs_Var *var,
const char *method,
struct pxs_Var *args);
int64_t pxs_getint(struct pxs_Var *var);
uint64_t pxs_getuint(struct pxs_Var *var);
double pxs_getfloat(struct pxs_Var *var);
bool pxs_getbool(struct pxs_Var *var);
char *pxs_getstring(struct pxs_Var *var);
pxs_Opaque pxs_gethost(struct pxs_Var *var);
bool pxs_varis(struct pxs_Var *var, enum pxs_VarType var_type);
void pxs_set_filereader(LoadFileFn func);
void pxs_set_filewriter(WriteFileFn func);
void pxs_set_dirreader(ReadDirFn func);
void pxs_freevar(struct pxs_Var *var);
void pxs_startthread(void);
void pxs_stopthread(void);
void pxs_clearstate(bool gc_collect);
struct pxs_Var *pxs_call(struct pxs_Var *runtime, const char *method, struct pxs_Var *args);
struct pxs_Var *pxs_tostring(struct pxs_Var *runtime, struct pxs_Var *var);
struct pxs_Var *pxs_newlist(void);
int32_t pxs_listadd(struct pxs_Var *list,
struct pxs_Var *item);
struct pxs_Var *pxs_listget(struct pxs_Var *list,
int32_t index);
bool pxs_listset(struct pxs_Var *list,
int32_t index,
struct pxs_Var *item);
int32_t pxs_listlen(struct pxs_Var *list);
struct pxs_Var *pxs_varcall(struct pxs_Var *runtime,
struct pxs_Var *var_func,
struct pxs_Var *args);
struct pxs_Var *pxs_newcopy(struct pxs_Var *item);
pxs_VarT pxs_objectget(pxs_VarT runtime, pxs_VarT obj, const char *key);
bool pxs_objectset(pxs_VarT runtime, pxs_VarT obj, const char *key, pxs_VarT value);
pxs_Opaque pxs_host_fromidx(int32_t idx);
#ifdef __cplusplus
} #endif
#endif