1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-02-02 15:09:23 -05:00

Factor smjs_get_global_object out of init_smjs.

This commit is contained in:
Miciah Dashiel Butler Masters 2005-12-24 03:39:24 +00:00 committed by Miciah Dashiel Butler Masters
parent 2a0653a9f2
commit 3174c533b0
4 changed files with 50 additions and 12 deletions

View File

@ -3,6 +3,6 @@ include $(top_builddir)/Makefile.config
INCLUDES += $(SPIDERMONKEY_CFLAGS)
OBJS = smjs.o core.o hooks.o elinks_object.o cache_object.o
OBJS = smjs.o core.o global_object.o hooks.o elinks_object.o cache_object.o
include $(top_srcdir)/Makefile.lib

View File

@ -12,6 +12,7 @@
#include "scripting/scripting.h"
#include "scripting/smjs/core.h"
#include "scripting/smjs/elinks_object.h"
#include "scripting/smjs/global_object.h"
#include "scripting/smjs/smjs.h"
#include "util/string.h"
@ -97,12 +98,6 @@ smjs_load_hooks(void)
void
init_smjs(struct module *module)
{
static const JSClass global_class = {
"global", 0,
JS_PropertyStub, JS_PropertyStub,
JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
JSObject *global_object;
smjs_rt = JS_NewRuntime(1L * 1024L * 1024L);
@ -117,11 +112,7 @@ init_smjs(struct module *module)
JS_SetErrorReporter(smjs_ctx, error_reporter);
global_object = JS_NewObject(smjs_ctx, (JSClass *) &global_class,
NULL, NULL);
if (!global_object) return;
JS_InitStandardClasses(smjs_ctx, global_object);
global_object = smjs_get_global_object();
smjs_elinks_object = smjs_get_elinks_object(global_object);

View File

@ -0,0 +1,39 @@
/* The global object. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "elinks.h"
#include "ecmascript/spidermonkey/util.h"
#include "scripting/scripting.h"
#include "scripting/smjs/core.h"
#include "scripting/smjs/global_object.h"
JSObject *smjs_global_object;
static const JSClass global_class = {
"global", 0,
JS_PropertyStub, JS_PropertyStub,
JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
JSObject *
smjs_get_global_object(void)
{
JSObject *jsobj;
assert(smjs_ctx);
jsobj = JS_NewObject(smjs_ctx, (JSClass *) &global_class, NULL, NULL);
if (!jsobj) return NULL;
JS_InitStandardClasses(smjs_ctx, jsobj);
return jsobj;
}

View File

@ -0,0 +1,8 @@
#ifndef EL__SCRIPTING_SMJS_GLOBAL_OBJECT_H
#define EL__SCRIPTING_SMJS_GLOBAL_OBJECT_H
#include "ecmascript/spidermonkey/util.h"
JSObject *smjs_get_global_object(void);
#endif