static JSBool InitAndSealCTypesClass(JSContext* cx, JSObject* global) { // Init the ctypes object. if (!JS_InitCTypesClass(cx, global)) return false; // Set callbacks for charset conversion and such. jsval ctypes; if (!JS_GetProperty(cx, global, "ctypes", &ctypes)) return false; JS_SetCTypesCallbacks(JSVAL_TO_OBJECT(ctypes), &sCallbacks); // Seal up Object, Function, Array and Error and their prototypes. (This // single object instance is shared amongst everyone who imports the ctypes // module.) if (!SealObjectAndPrototype(cx, global, "Object") || !SealObjectAndPrototype(cx, global, "Function") || !SealObjectAndPrototype(cx, global, "Array") || !SealObjectAndPrototype(cx, global, "Error")) return false; // Finally, seal the global object, for good measure. (But not recursively; // this breaks things.) return JS_FreezeObject(cx, global); }
static bool InitAndSealCTypesClass(JSContext* cx, JS::Handle<JSObject*> global) { // Init the ctypes object. if (!JS_InitCTypesClass(cx, global)) return false; // Set callbacks for charset conversion and such. JS::Rooted<JS::Value> ctypes(cx); if (!JS_GetProperty(cx, global, "ctypes", &ctypes)) return false; JS_SetCTypesCallbacks(ctypes.toObjectOrNull(), &sCallbacks); // Seal up Object, Function, Array and Error and their prototypes. (This // single object instance is shared amongst everyone who imports the ctypes // module.) if (!SealObjectAndPrototype(cx, global, "Object") || !SealObjectAndPrototype(cx, global, "Function") || !SealObjectAndPrototype(cx, global, "Array") || !SealObjectAndPrototype(cx, global, "Error")) return false; return true; }