Skip to content
Snippets Groups Projects
Commit 7ffb2004 authored by rswindell's avatar rswindell
Browse files

Created js.global for easy reference to the global (top level) object.

parent b7899dd3
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,7 @@ enum { ...@@ -54,6 +54,7 @@ enum {
,PROP_BYTES ,PROP_BYTES
,PROP_MAXBYTES ,PROP_MAXBYTES
#endif #endif
,PROP_GLOBAL
}; };
static JSBool js_get(JSContext *cx, JSObject *obj, jsval id, jsval *vp) static JSBool js_get(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
...@@ -107,6 +108,13 @@ static JSBool js_get(JSContext *cx, JSObject *obj, jsval id, jsval *vp) ...@@ -107,6 +108,13 @@ static JSBool js_get(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
case PROP_MAXBYTES: case PROP_MAXBYTES:
JS_NewNumberValue(cx,cx->runtime->gcMaxBytes,vp); JS_NewNumberValue(cx,cx->runtime->gcMaxBytes,vp);
break; break;
case PROP_GLOBAL:
*vp = OBJECT_TO_JSVAL(cx->globalObject);
break;
#else
case PROP_GLOBAL:
*vp = OBJECT_TO_JSVAL(JS_GetParent(cx,obj));
break;
#endif #endif
} }
...@@ -172,6 +180,7 @@ static jsSyncPropertySpec js_properties[] = { ...@@ -172,6 +180,7 @@ static jsSyncPropertySpec js_properties[] = {
{ "bytes", PROP_BYTES, PROP_FLAGS, 311 }, { "bytes", PROP_BYTES, PROP_FLAGS, 311 },
{ "max_bytes", PROP_MAXBYTES, JSPROP_ENUMERATE, 311 }, { "max_bytes", PROP_MAXBYTES, JSPROP_ENUMERATE, 311 },
#endif #endif
{ "global", PROP_GLOBAL, PROP_FLAGS, 313 },
{0} {0}
}; };
...@@ -191,6 +200,7 @@ static char* prop_desc[] = { ...@@ -191,6 +200,7 @@ static char* prop_desc[] = {
,"number of heap bytes currently in use - <small>READ ONLY</small>" ,"number of heap bytes currently in use - <small>READ ONLY</small>"
,"maximum number of bytes available for heap" ,"maximum number of bytes available for heap"
#endif #endif
,"global (top level) object - <small>READ ONLY</small>"
,NULL ,NULL
}; };
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment