ocaml style rooting macros
This commit is contained in:
@@ -146,10 +146,22 @@ typedef struct JSGCRef {
|
||||
struct JSGCRef *prev;
|
||||
} JSGCRef;
|
||||
|
||||
/* JSLocalRef - GC updates C locals through pointers (OCaml-style) */
|
||||
typedef struct JSLocalRef {
|
||||
JSValue *ptr;
|
||||
struct JSLocalRef *prev;
|
||||
} JSLocalRef;
|
||||
|
||||
/* stack of JSGCRef */
|
||||
JSValue *JS_PushGCRef(JSContext *ctx, JSGCRef *ref);
|
||||
JSValue JS_PopGCRef(JSContext *ctx, JSGCRef *ref);
|
||||
|
||||
/* JS_FRAME/JS_ROOT/JS_LOCAL helpers (for use from cell.h macros) */
|
||||
JSGCRef *JS_GetGCFrame(JSContext *ctx);
|
||||
JSLocalRef *JS_GetLocalFrame(JSContext *ctx);
|
||||
void JS_PushLocalRef(JSContext *ctx, JSLocalRef *ref);
|
||||
void JS_RestoreFrame(JSContext *ctx, JSGCRef *gc_frame, JSLocalRef *local_frame);
|
||||
|
||||
#define JS_PUSH_VALUE(ctx, v) do { JS_PushGCRef(ctx, &v ## _ref); v ## _ref.val = v; } while (0)
|
||||
#define JS_POP_VALUE(ctx, v) v = JS_PopGCRef(ctx, &v ## _ref)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user