This repository has been archived by the owner on Aug 18, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved our global object creation, etc into a separate file.
- Loading branch information
Showing
4 changed files
with
90 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "global.h" | ||
|
||
static JSBool enumerate(JSContext *js_context, JSObject *obj) | ||
{ | ||
return JS_EnumerateStandardClasses(js_context, obj); | ||
} | ||
|
||
static JSBool resolve(JSContext *js_context, JSObject *obj, jsval id, uintN flags, JSObject **objp) | ||
{ | ||
if ((flags & JSRESOLVE_ASSIGNING) == 0) | ||
{ | ||
JSBool resolved_p; | ||
|
||
if (!JS_ResolveStandardClass(js_context, obj, id, &resolved_p)) | ||
return JS_FALSE; | ||
|
||
if (resolved_p) | ||
*objp = obj; | ||
} | ||
|
||
return JS_TRUE; | ||
} | ||
|
||
static JSClass OurGlobalClass = { | ||
"global", JSCLASS_NEW_RESOLVE | JSCLASS_GLOBAL_FLAGS, | ||
JS_PropertyStub, // addProperty | ||
JS_PropertyStub, // delProperty | ||
JS_PropertyStub, // getProperty | ||
JS_PropertyStub, // setProperty | ||
enumerate, | ||
(JSResolveOp) resolve, | ||
JS_ConvertStub, | ||
JS_FinalizeStub, | ||
JSCLASS_NO_OPTIONAL_MEMBERS | ||
}; | ||
|
||
JSObject* create_global_object(OurContext* context) | ||
{ | ||
JS_NewObject(context->js, &OurGlobalClass, NULL, NULL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef JOHNSON_SPIDERMONKEY_GLOBAL_H | ||
#define JOHNSON_SPIDERMONKEY_GLOBAL_H | ||
|
||
#include "spidermonkey.h" | ||
#include "context.h" | ||
|
||
JSObject* create_global_object(OurContext* context); | ||
|
||
#endif |