ref: 84faaff8ff8d6e71bbd316edc633d90a38def6ec
parent: 653830808758ab3396ba111cad8ade7d80e25228
author: Tor Andersson <tor.andersson@artifex.com>
date: Sat Nov 29 11:12:30 EST 2014
Add user context pointer and flag argument to js_State constructor.
--- a/jsi.h
+++ b/jsi.h
@@ -122,6 +122,7 @@
struct js_State
{
void *actx;
+ void *uctx;
js_Alloc alloc;
js_Panic panic;
--- a/jsstate.c
+++ b/jsstate.c
@@ -154,8 +154,18 @@
return old;
}
-js_State *js_newstate(js_Alloc alloc, void *actx)
+void js_setcontext(js_State *J, void *uctx)
{
+ J->uctx = uctx;
+}
+
+void *js_getcontext(js_State *J)
+{
+ return J->uctx;
+}
+
+js_State *js_newstate(js_Alloc alloc, void *actx, void *uctx, int flags)
+{
js_State *J;
if (!alloc)
@@ -165,6 +175,7 @@
if (!J)
return NULL;
memset(J, 0, sizeof(*J));
+ J->uctx = uctx;
J->actx = actx;
J->alloc = alloc;
--- a/main.c
+++ b/main.c
@@ -117,7 +117,7 @@
js_State *J;
int i;
- J = js_newstate(NULL, NULL);
+ J = js_newstate(NULL, NULL, NULL, 0);
js_newcfunction(J, jsB_gc, 0);
js_setglobal(J, "gc");
--- a/mujs.h
+++ b/mujs.h
@@ -31,7 +31,9 @@
typedef void (*js_CFunction)(js_State *J);
/* Basic functions */
-js_State *js_newstate(js_Alloc alloc, void *actx);
+js_State *js_newstate(js_Alloc alloc, void *actx, void *uctx, int flags);
+void js_setcontext(js_State *J, void *uctx);
+void *js_getcontext(js_State *J);
js_Panic js_atpanic(js_State *J, js_Panic panic);
void js_freestate(js_State *J);
void js_gc(js_State *J, int report);