From d6ecf895ce5eb22c639c14d19dd18534c20fb5be Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Sat, 24 Dec 2005 03:40:59 +0000 Subject: [PATCH] Make global_object a global with the new name smjs_global_object and create smjs_init_global_object to initialise the global. --- src/scripting/smjs/core.c | 6 ++---- src/scripting/smjs/global_object.c | 8 +++++++- src/scripting/smjs/global_object.h | 7 ++++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/scripting/smjs/core.c b/src/scripting/smjs/core.c index 1289c5bd..ac35a60d 100644 --- a/src/scripting/smjs/core.c +++ b/src/scripting/smjs/core.c @@ -98,8 +98,6 @@ smjs_load_hooks(void) void init_smjs(struct module *module) { - JSObject *global_object; - smjs_rt = JS_NewRuntime(1L * 1024L * 1024L); if (!smjs_rt) return; @@ -112,9 +110,9 @@ init_smjs(struct module *module) JS_SetErrorReporter(smjs_ctx, error_reporter); - global_object = smjs_get_global_object(); + smjs_init_global_object(); - smjs_elinks_object = smjs_get_elinks_object(global_object); + smjs_elinks_object = smjs_get_elinks_object(smjs_global_object); smjs_load_hooks(); } diff --git a/src/scripting/smjs/global_object.c b/src/scripting/smjs/global_object.c index 7a0f2498..f2c51102 100644 --- a/src/scripting/smjs/global_object.c +++ b/src/scripting/smjs/global_object.c @@ -22,7 +22,7 @@ static const JSClass global_class = { JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub }; -JSObject * +static JSObject * smjs_get_global_object(void) { JSObject *jsobj; @@ -37,3 +37,9 @@ smjs_get_global_object(void) return jsobj; } + +void +smjs_init_global_object(void) +{ + smjs_global_object = smjs_get_global_object(); +} diff --git a/src/scripting/smjs/global_object.h b/src/scripting/smjs/global_object.h index 076b1389..c7ff510a 100644 --- a/src/scripting/smjs/global_object.h +++ b/src/scripting/smjs/global_object.h @@ -3,6 +3,11 @@ #include "ecmascript/spidermonkey/util.h" -JSObject *smjs_get_global_object(void); +/* The root of the object hierarchy. If object 'foo' has this as its parent, + * you can use foo's method and properties with 'foo.'. */ +extern JSObject *smjs_global_object; + +/* Create the global object and assign it to smjs_global_object. */ +void smjs_init_global_object(void); #endif