From c2021ab74da2048fc330c8185d98f2c9331c8149 Mon Sep 17 00:00:00 2001 From: lemon Date: Mon, 16 Jun 2025 11:57:53 +0200 Subject: + pez_setglobal --- pez.c | 9 +++++++++ pez.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/pez.c b/pez.c index 52744ad..f341c78 100644 --- a/pez.c +++ b/pez.c @@ -4539,6 +4539,15 @@ pez_pushuserobj(PezContext *cx, const PezUserType *typeid, void *data) return push(cx, o); } +bool +pez_setglobal(PezContext *cx, const char *name) +{ + Val k, v; + TRY(box_str(cx, &k, name, strlen(name))); + v = pop(cx); + return putglobal(cx, k, v); +} + bool pez_isvoid(PezContext *cx, int idx) { diff --git a/pez.h b/pez.h index d29344f..62946d2 100644 --- a/pez.h +++ b/pez.h @@ -72,6 +72,8 @@ 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_setglobal(PezContext *, const char *name); + bool pez_isvoid(PezContext *, int idx); bool pez_isnumber(PezContext *, int idx); bool pez_isbool(PezContext *, int idx); -- cgit v1.2.3