summaryrefslogtreecommitdiff
path: root/pez.h
diff options
context:
space:
mode:
Diffstat (limited to 'pez.h')
-rw-r--r--pez.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/pez.h b/pez.h
index 075eb41..f99b58b 100644
--- a/pez.h
+++ b/pez.h
@@ -19,7 +19,8 @@ enum {
PEZ_TTuple,
PEZ_TRecord,
PEZ_TArray,
- PEZ_TDilambda
+ PEZ_TDilambda,
+ PEZ_TUserObj,
};
typedef enum PezError {
@@ -29,12 +30,17 @@ typedef enum PezError {
PEZ_ERuntime,
} PezError;
-
typedef struct PezContext PezContext;
typedef void *PezAllocFn(void *userdata, void *ptr, size_t oldsize, size_t newsize);
typedef bool PezCFn(PezContext *, int argc);
typedef int PezReadFn(void *userdata, char *dst, int n);
+typedef struct PezUserType {
+ const char *name;
+ size_t size;
+ void (*dtor)(void *);
+} PezUserType;
+
PezContext *pez_new(PezAllocFn *alloc, void *userdata, size_t stacksize);
void pez_del(PezContext *);
@@ -63,6 +69,7 @@ bool pez_pushnumber(PezContext *, PezNumber);
bool pez_pushint(PezContext *, int);
bool pez_pushstring(PezContext *, const char *str, int len);
bool pez_pushglobal(PezContext *, const char *name);
+bool pez_pushuserobj(PezContext *, const PezUserType *, void *data);
bool pez_isvoid(PezContext *, int idx);
bool pez_isnumber(PezContext *, int idx);
@@ -70,6 +77,7 @@ bool pez_isbool(PezContext *, int idx);
bool pez_isstring(PezContext *, int idx);
bool pez_isfunction(PezContext *, int idx);
bool pez_isarray(PezContext *, int idx);
+bool pez_isuserobj(PezContext *, const PezUserType *, int idx);
bool pez_truthy(PezContext *, int idx);
int pez_typeof(PezContext *, int idx);
const char *pez_typename(PezContext *, int idx);
@@ -79,6 +87,7 @@ bool pez_checksig(PezContext *, int argc, const char *fn, const char *sig);
bool pez_getnumber(PezContext *, PezNumber *, int idx);
bool pez_getbool(PezContext *, bool *, int idx);
const char *pez_getstring(PezContext *, char buf[8], int idx);
+void *pez_getuserobj(PezContext *cx, const PezUserType *, int idx);
const char *pez_fnname(PezContext *, int idx);
int pez_length(PezContext *cx, int idx);