1 /* The global object. */
2 
3 #ifdef HAVE_CONFIG_H
4 #include "config.h"
5 #endif
6 
7 #include "elinks.h"
8 
9 #include "ecmascript/spidermonkey/util.h"
10 #include "scripting/scripting.h"
11 #include "scripting/smjs/core.h"
12 #include "scripting/smjs/global_object.h"
13 
14 
15 JSObject *smjs_global_object;
16 
17 
18 static const JSClass global_class = {
19 	"global", 0,
20 	JS_PropertyStub, JS_PropertyStub,
21 	JS_PropertyStub, JS_PropertyStub,
22 	JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
23 };
24 
25 static JSObject *
smjs_get_global_object(void)26 smjs_get_global_object(void)
27 {
28 	JSObject *jsobj;
29 
30 	assert(smjs_ctx);
31 
32 	jsobj  = JS_NewObject(smjs_ctx, (JSClass *) &global_class, NULL, NULL);
33 
34 	if (!jsobj) return NULL;
35 
36 	JS_InitStandardClasses(smjs_ctx, jsobj);
37 
38 	return jsobj;
39 }
40 
41 void
smjs_init_global_object(void)42 smjs_init_global_object(void)
43 {
44 	smjs_global_object = smjs_get_global_object();
45 }
46