Bug 1663365 - Various stylistic cleanups to ctypes-related functionality in jsfriendapi.h, in advance of a move into a separate header. r=jandem

Differential Revision: https://phabricator.services.mozilla.com/D95670
This commit is contained in:
Jeff Walden 2020-11-07 00:04:18 +00:00
Родитель a6e8f36d35
Коммит b0435c3949
14 изменённых файлов: 101 добавлений и 67 удалений

Просмотреть файл

@ -52,14 +52,14 @@ bool DefineChromeWorkerFunctions(JSContext* aCx,
#ifdef BUILD_CTYPES #ifdef BUILD_CTYPES
{ {
JS::Rooted<JS::Value> ctypes(aCx); JS::Rooted<JS::Value> ctypes(aCx);
if (!JS_InitCTypesClass(aCx, aGlobal) || if (!JS::InitCTypesClass(aCx, aGlobal) ||
!JS_GetProperty(aCx, aGlobal, "ctypes", &ctypes)) { !JS_GetProperty(aCx, aGlobal, "ctypes", &ctypes)) {
return false; return false;
} }
static const JSCTypesCallbacks callbacks = {UnicodeToNative}; static const JS::CTypesCallbacks callbacks = {UnicodeToNative};
JS_SetCTypesCallbacks(ctypes.toObjectOrNull(), &callbacks); JS::SetCTypesCallbacks(ctypes.toObjectOrNull(), &callbacks);
} }
#endif // BUILD_CTYPES #endif // BUILD_CTYPES

Просмотреть файл

@ -569,24 +569,24 @@ bool ContentSecurityPolicyAllows(JSContext* aCx, JS::HandleString aCode) {
return worker->IsEvalAllowed(); return worker->IsEvalAllowed();
} }
void CTypesActivityCallback(JSContext* aCx, js::CTypesActivityType aType) { void CTypesActivityCallback(JSContext* aCx, JS::CTypesActivityType aType) {
WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx); WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx);
worker->AssertIsOnWorkerThread(); worker->AssertIsOnWorkerThread();
switch (aType) { switch (aType) {
case js::CTYPES_CALL_BEGIN: case JS::CTypesActivityType::BeginCall:
worker->BeginCTypesCall(); worker->BeginCTypesCall();
break; break;
case js::CTYPES_CALL_END: case JS::CTypesActivityType::EndCall:
worker->EndCTypesCall(); worker->EndCTypesCall();
break; break;
case js::CTYPES_CALLBACK_BEGIN: case JS::CTypesActivityType::BeginCallback:
worker->BeginCTypesCallback(); worker->BeginCTypesCallback();
break; break;
case js::CTYPES_CALLBACK_END: case JS::CTypesActivityType::EndCallback:
worker->EndCTypesCallback(); worker->EndCTypesCallback();
break; break;
@ -732,7 +732,7 @@ bool InitJSContextForWorker(WorkerPrivate* aWorkerPrivate,
JS_AddInterruptCallback(aWorkerCx, InterruptCallback); JS_AddInterruptCallback(aWorkerCx, InterruptCallback);
js::SetCTypesActivityCallback(aWorkerCx, CTypesActivityCallback); JS::SetCTypesActivityCallback(aWorkerCx, CTypesActivityCallback);
#ifdef JS_GC_ZEAL #ifdef JS_GC_ZEAL
JS_SetGCZeal(aWorkerCx, settings.gcZeal, settings.gcZealFrequency); JS_SetGCZeal(aWorkerCx, settings.gcZeal, settings.gcZealFrequency);

Просмотреть файл

@ -67,7 +67,9 @@ using mozilla::IsAsciiAlpha;
using mozilla::IsAsciiDigit; using mozilla::IsAsciiDigit;
using JS::AutoCheckCannotGC; using JS::AutoCheckCannotGC;
using JS::AutoCTypesActivityCallback;
using JS::AutoStableStringChars; using JS::AutoStableStringChars;
using JS::CTypesActivityType;
namespace js::ctypes { namespace js::ctypes {
@ -441,7 +443,7 @@ static bool Join(JSContext* cx, unsigned argc, Value* vp);
*******************************************************************************/ *******************************************************************************/
// Class representing the 'ctypes' object itself. This exists to contain the // Class representing the 'ctypes' object itself. This exists to contain the
// JSCTypesCallbacks set of function pointers. // JS::CTypesCallbacks set of function pointers.
static const JSClass sCTypesGlobalClass = { static const JSClass sCTypesGlobalClass = {
"ctypes", JSCLASS_HAS_RESERVED_SLOTS(CTYPESGLOBAL_SLOTS)}; "ctypes", JSCLASS_HAS_RESERVED_SLOTS(CTYPESGLOBAL_SLOTS)};
@ -2343,8 +2345,8 @@ bool IsCTypesGlobal(HandleValue v) {
return v.isObject() && IsCTypesGlobal(&v.toObject()); return v.isObject() && IsCTypesGlobal(&v.toObject());
} }
// Get the JSCTypesCallbacks struct from the 'ctypes' object 'obj'. // Get the JS::CTypesCallbacks struct from the 'ctypes' object 'obj'.
const JSCTypesCallbacks* GetCallbacks(JSObject* obj) { const JS::CTypesCallbacks* GetCallbacks(JSObject* obj) {
MOZ_ASSERT(IsCTypesGlobal(obj)); MOZ_ASSERT(IsCTypesGlobal(obj));
Value result = JS::GetReservedSlot(obj, SLOT_CALLBACKS); Value result = JS::GetReservedSlot(obj, SLOT_CALLBACKS);
@ -2352,7 +2354,7 @@ const JSCTypesCallbacks* GetCallbacks(JSObject* obj) {
return nullptr; return nullptr;
} }
return static_cast<const JSCTypesCallbacks*>(result.toPrivate()); return static_cast<const JS::CTypesCallbacks*>(result.toPrivate());
} }
// Utility function to access a property of an object as an object // Utility function to access a property of an object as an object
@ -2380,7 +2382,8 @@ static bool GetObjectProperty(JSContext* cx, HandleObject obj,
using namespace js; using namespace js;
using namespace js::ctypes; using namespace js::ctypes;
JS_PUBLIC_API bool JS_InitCTypesClass(JSContext* cx, HandleObject global) { JS_PUBLIC_API bool JS::InitCTypesClass(JSContext* cx,
Handle<JSObject*> global) {
// attach ctypes property to global object // attach ctypes property to global object
RootedObject ctypes(cx, JS_NewObject(cx, &sCTypesGlobalClass)); RootedObject ctypes(cx, JS_NewObject(cx, &sCTypesGlobalClass));
if (!ctypes) { if (!ctypes) {
@ -2436,19 +2439,21 @@ JS_PUBLIC_API bool JS_InitCTypesClass(JSContext* cx, HandleObject global) {
return JS_FreezeObject(cx, ctypes); return JS_FreezeObject(cx, ctypes);
} }
JS_PUBLIC_API void JS_SetCTypesCallbacks(JSObject* ctypesObj, JS_PUBLIC_API void JS::SetCTypesCallbacks(JSObject* ctypesObj,
const JSCTypesCallbacks* callbacks) { const CTypesCallbacks* callbacks) {
MOZ_ASSERT(callbacks); MOZ_ASSERT(callbacks);
MOZ_ASSERT(IsCTypesGlobal(ctypesObj)); MOZ_ASSERT(IsCTypesGlobal(ctypesObj));
// Set the callbacks on a reserved slot. // Set the callbacks on a reserved slot.
JS_SetReservedSlot(ctypesObj, SLOT_CALLBACKS, JS_SetReservedSlot(ctypesObj, SLOT_CALLBACKS,
PrivateValue(const_cast<JSCTypesCallbacks*>(callbacks))); PrivateValue(const_cast<CTypesCallbacks*>(callbacks)));
} }
namespace js { namespace js {
JS_FRIEND_API size_t SizeOfDataIfCDataObject(mozilla::MallocSizeOf mallocSizeOf, namespace ctypes {
size_t SizeOfDataIfCDataObject(mozilla::MallocSizeOf mallocSizeOf,
JSObject* obj) { JSObject* obj) {
if (!CData::IsCData(obj)) { if (!CData::IsCData(obj)) {
return 0; return 0;
@ -2470,8 +2475,6 @@ JS_FRIEND_API size_t SizeOfDataIfCDataObject(mozilla::MallocSizeOf mallocSizeOf,
return n; return n;
} }
namespace ctypes {
/******************************************************************************* /*******************************************************************************
** Type conversion functions ** Type conversion functions
*******************************************************************************/ *******************************************************************************/
@ -7088,8 +7091,8 @@ bool FunctionType::Call(JSContext* cx, unsigned argc, Value* vp) {
} }
// Let the runtime callback know that we are about to call into C. // Let the runtime callback know that we are about to call into C.
js::AutoCTypesActivityCallback autoCallback(cx, js::CTYPES_CALL_BEGIN, AutoCTypesActivityCallback autoCallback(cx, CTypesActivityType::BeginCall,
js::CTYPES_CALL_END); CTypesActivityType::EndCall);
uintptr_t fn = *reinterpret_cast<uintptr_t*>(CData::GetData(obj)); uintptr_t fn = *reinterpret_cast<uintptr_t*>(CData::GetData(obj));
@ -7378,8 +7381,8 @@ void CClosure::ClosureStub(ffi_cif* cif, void* result, void** args,
bool CClosure::ArgClosure::operator()(JSContext* cx) { bool CClosure::ArgClosure::operator()(JSContext* cx) {
// Let the runtime callback know that we are about to call into JS again. The // Let the runtime callback know that we are about to call into JS again. The
// end callback will fire automatically when we exit this function. // end callback will fire automatically when we exit this function.
js::AutoCTypesActivityCallback autoCallback(cx, js::CTYPES_CALLBACK_BEGIN, AutoCTypesActivityCallback autoCallback(cx, CTypesActivityType::BeginCallback,
js::CTYPES_CALLBACK_END); CTypesActivityType::EndCallback);
RootedObject typeObj(cx, cinfo->typeObj); RootedObject typeObj(cx, cinfo->typeObj);
RootedObject thisObj(cx, cinfo->thisObj); RootedObject thisObj(cx, cinfo->thisObj);

Просмотреть файл

@ -388,14 +388,14 @@ struct ClosureInfo {
bool IsCTypesGlobal(HandleValue v); bool IsCTypesGlobal(HandleValue v);
bool IsCTypesGlobal(JSObject* obj); bool IsCTypesGlobal(JSObject* obj);
const JSCTypesCallbacks* GetCallbacks(JSObject* obj); const JS::CTypesCallbacks* GetCallbacks(JSObject* obj);
/******************************************************************************* /*******************************************************************************
** JSClass reserved slot definitions ** JSClass reserved slot definitions
*******************************************************************************/ *******************************************************************************/
enum CTypesGlobalSlot { enum CTypesGlobalSlot {
SLOT_CALLBACKS = 0, // pointer to JSCTypesCallbacks struct SLOT_CALLBACKS = 0, // pointer to JS::CTypesCallbacks struct
SLOT_ERRNO = 1, // Value for latest |errno| SLOT_ERRNO = 1, // Value for latest |errno|
SLOT_LASTERROR = SLOT_LASTERROR =
2, // Value for latest |GetLastError|, used only with Windows 2, // Value for latest |GetLastError|, used only with Windows
@ -512,7 +512,7 @@ ffi_type* GetFFIType(JSContext* cx, JSObject* obj);
JSString* GetName(JSContext* cx, HandleObject obj); JSString* GetName(JSContext* cx, HandleObject obj);
JSObject* GetProtoFromCtor(JSObject* obj, CTypeProtoSlot slot); JSObject* GetProtoFromCtor(JSObject* obj, CTypeProtoSlot slot);
JSObject* GetProtoFromType(JSContext* cx, JSObject* obj, CTypeProtoSlot slot); JSObject* GetProtoFromType(JSContext* cx, JSObject* obj, CTypeProtoSlot slot);
const JSCTypesCallbacks* GetCallbacksFromType(JSObject* obj); const JS::CTypesCallbacks* GetCallbacksFromType(JSObject* obj);
} // namespace CType } // namespace CType
namespace PointerType { namespace PointerType {

Просмотреть файл

@ -97,7 +97,7 @@ bool Library::Name(JSContext* cx, unsigned argc, Value* vp) {
} }
JSObject* Library::Create(JSContext* cx, HandleValue path, JSObject* Library::Create(JSContext* cx, HandleValue path,
const JSCTypesCallbacks* callbacks) { const JS::CTypesCallbacks* callbacks) {
RootedObject libraryObj(cx, JS_NewObject(cx, &sLibraryClass)); RootedObject libraryObj(cx, JS_NewObject(cx, &sLibraryClass));
if (!libraryObj) { if (!libraryObj) {
return nullptr; return nullptr;

Просмотреть файл

@ -11,7 +11,10 @@
#include "js/TypeDecls.h" #include "js/TypeDecls.h"
struct JSCTypesCallbacks; namespace JS {
struct CTypesCallbacks;
} // namespace JS
struct PRLibrary; struct PRLibrary;
namespace js { namespace js {
@ -23,7 +26,7 @@ namespace Library {
MOZ_MUST_USE bool Name(JSContext* cx, unsigned argc, JS::Value* vp); MOZ_MUST_USE bool Name(JSContext* cx, unsigned argc, JS::Value* vp);
JSObject* Create(JSContext* cx, JS::HandleValue path, JSObject* Create(JSContext* cx, JS::HandleValue path,
const JSCTypesCallbacks* callbacks); const JS::CTypesCallbacks* callbacks);
bool IsLibrary(JSObject* obj); bool IsLibrary(JSObject* obj);
PRLibrary* GetLibrary(JSObject* obj); PRLibrary* GetLibrary(JSObject* obj);

Просмотреть файл

@ -667,28 +667,30 @@ extern JS_PUBLIC_API bool IsProfileTimelineRecordingEnabled();
} // namespace JS } // namespace JS
#ifdef JS_HAS_CTYPES #ifdef JS_HAS_CTYPES
namespace JS {
/** /**
* Initialize the 'ctypes' object on a global variable 'obj'. The 'ctypes' * Initialize the 'ctypes' object on a global variable 'obj'. The 'ctypes'
* object will be sealed. * object will be sealed.
*/ */
extern JS_PUBLIC_API bool JS_InitCTypesClass(JSContext* cx, extern JS_PUBLIC_API bool InitCTypesClass(JSContext* cx,
JS::HandleObject global); JS::Handle<JSObject*> global);
/** /**
* Convert a unicode string 'source' of length 'slen' to the platform native * Convert a unicode string 'source' of length 'slen' to the platform native
* charset, returning a null-terminated string allocated with JS_malloc. On * charset, returning a null-terminated string allocated with JS_malloc. On
* failure, this function should report an error. * failure, this function should report an error.
*/ */
using JSCTypesUnicodeToNativeFun = char* (*)(JSContext*, const char16_t*, using CTypesUnicodeToNativeFun = char* (*)(JSContext*, const char16_t*, size_t);
size_t);
/** /**
* Set of function pointers that ctypes can use for various internal functions. * Set of function pointers that ctypes can use for various internal functions.
* See JS_SetCTypesCallbacks below. Providing nullptr for a function is safe, * See JS::SetCTypesCallbacks below. Providing nullptr for a function is safe
* and will result in the applicable ctypes functionality not being available. * and will result in the applicable ctypes functionality not being available.
*/ */
struct JSCTypesCallbacks { struct CTypesCallbacks {
JSCTypesUnicodeToNativeFun unicodeToNative; CTypesUnicodeToNativeFun unicodeToNative;
}; };
/** /**
@ -697,8 +699,11 @@ struct JSCTypesCallbacks {
* may safely be altered after calling this function and without having * may safely be altered after calling this function and without having
* to call this function again. * to call this function again.
*/ */
extern JS_PUBLIC_API void JS_SetCTypesCallbacks( extern JS_PUBLIC_API void SetCTypesCallbacks(JSObject* ctypesObj,
JSObject* ctypesObj, const JSCTypesCallbacks* callbacks); const CTypesCallbacks* callbacks);
} // namespace JS
#endif #endif
/* /*

Просмотреть файл

@ -737,14 +737,13 @@ JS_FRIEND_API void js::SetScriptEnvironmentPreparer(
cx->runtime()->scriptEnvironmentPreparer = preparer; cx->runtime()->scriptEnvironmentPreparer = preparer;
} }
JS_FRIEND_API void js::SetCTypesActivityCallback(JSContext* cx, JS_FRIEND_API void JS::SetCTypesActivityCallback(JSContext* cx,
CTypesActivityCallback cb) { CTypesActivityCallback cb) {
cx->runtime()->ctypesActivityCallback = cb; cx->runtime()->ctypesActivityCallback = cb;
} }
js::AutoCTypesActivityCallback::AutoCTypesActivityCallback( JS::AutoCTypesActivityCallback::AutoCTypesActivityCallback(
JSContext* cx, js::CTypesActivityType beginType, JSContext* cx, CTypesActivityType beginType, CTypesActivityType endType)
js::CTypesActivityType endType)
: cx(cx), : cx(cx),
callback(cx->runtime()->ctypesActivityCallback), callback(cx->runtime()->ctypesActivityCallback),
endType(endType) { endType(endType) {

Просмотреть файл

@ -300,11 +300,6 @@ extern JS_FRIEND_API void IterateGrayObjects(
extern JS_FRIEND_API bool CheckGrayMarkingState(JSRuntime* rt); extern JS_FRIEND_API bool CheckGrayMarkingState(JSRuntime* rt);
#endif #endif
#ifdef JS_HAS_CTYPES
extern JS_FRIEND_API size_t
SizeOfDataIfCDataObject(mozilla::MallocSizeOf mallocSizeOf, JSObject* obj);
#endif
// Note: this returns nullptr iff |zone| is the atoms zone. // Note: this returns nullptr iff |zone| is the atoms zone.
extern JS_FRIEND_API JS::Realm* GetAnyRealmInZone(JS::Zone* zone); extern JS_FRIEND_API JS::Realm* GetAnyRealmInZone(JS::Zone* zone);
@ -648,20 +643,31 @@ extern JS_FRIEND_API void PrepareScriptEnvironmentAndInvoke(
JS_FRIEND_API void SetScriptEnvironmentPreparer( JS_FRIEND_API void SetScriptEnvironmentPreparer(
JSContext* cx, ScriptEnvironmentPreparer* preparer); JSContext* cx, ScriptEnvironmentPreparer* preparer);
enum CTypesActivityType { } // namespace js
CTYPES_CALL_BEGIN,
CTYPES_CALL_END, namespace JS {
CTYPES_CALLBACK_BEGIN,
CTYPES_CALLBACK_END /**
* The type of ctypes activity that is occurring.
*/
enum class CTypesActivityType {
BeginCall,
EndCall,
BeginCallback,
EndCallback,
}; };
/**
* The signature of a function invoked at the leading or trailing edge of ctypes
* activity.
*/
using CTypesActivityCallback = void (*)(JSContext*, CTypesActivityType); using CTypesActivityCallback = void (*)(JSContext*, CTypesActivityType);
/** /**
* Sets a callback that is run whenever js-ctypes is about to be used when * Sets a callback that is run whenever js-ctypes is about to be used when
* calling into C. * calling into C.
*/ */
JS_FRIEND_API void SetCTypesActivityCallback(JSContext* cx, extern JS_FRIEND_API void SetCTypesActivityCallback(JSContext* cx,
CTypesActivityCallback cb); CTypesActivityCallback cb);
class MOZ_RAII JS_FRIEND_API AutoCTypesActivityCallback { class MOZ_RAII JS_FRIEND_API AutoCTypesActivityCallback {
@ -673,7 +679,9 @@ class MOZ_RAII JS_FRIEND_API AutoCTypesActivityCallback {
public: public:
AutoCTypesActivityCallback(JSContext* cx, CTypesActivityType beginType, AutoCTypesActivityCallback(JSContext* cx, CTypesActivityType beginType,
CTypesActivityType endType); CTypesActivityType endType);
~AutoCTypesActivityCallback() { DoEndCallback(); } ~AutoCTypesActivityCallback() { DoEndCallback(); }
void DoEndCallback() { void DoEndCallback() {
if (callback) { if (callback) {
callback(cx, endType); callback(cx, endType);
@ -682,6 +690,10 @@ class MOZ_RAII JS_FRIEND_API AutoCTypesActivityCallback {
} }
}; };
} // namespace JS
namespace js {
// Abstract base class for objects that build allocation metadata for JavaScript // Abstract base class for objects that build allocation metadata for JavaScript
// values. // values.
struct AllocationMetadataBuilder { struct AllocationMetadataBuilder {

Просмотреть файл

@ -10100,7 +10100,7 @@ static JSObject* NewGlobalObject(JSContext* cx, JS::RealmOptions& options,
"having its [[Prototype]] be immutable"); "having its [[Prototype]] be immutable");
#ifdef JS_HAS_CTYPES #ifdef JS_HAS_CTYPES
if (!fuzzingSafe && !JS_InitCTypesClass(cx, glob)) { if (!fuzzingSafe && !JS::InitCTypesClass(cx, glob)) {
return nullptr; return nullptr;
} }
#endif #endif

Просмотреть файл

@ -3922,13 +3922,14 @@ void JSObject::addSizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf,
} else if (is<WeakCollectionObject>()) { } else if (is<WeakCollectionObject>()) {
info->objectsMallocHeapMisc += info->objectsMallocHeapMisc +=
as<WeakCollectionObject>().sizeOfExcludingThis(mallocSizeOf); as<WeakCollectionObject>().sizeOfExcludingThis(mallocSizeOf);
#ifdef JS_HAS_CTYPES
} else {
// This must be the last case.
info->objectsMallocHeapMisc +=
js::SizeOfDataIfCDataObject(mallocSizeOf, const_cast<JSObject*>(this));
#endif
} }
#ifdef JS_HAS_CTYPES
else {
// This must be the last case.
info->objectsMallocHeapMisc += ctypes::SizeOfDataIfCDataObject(
mallocSizeOf, const_cast<JSObject*>(this));
}
#endif
} }
size_t JSObject::sizeOfIncludingThisInNursery() const { size_t JSObject::sizeOfIncludingThisInNursery() const {

Просмотреть файл

@ -1112,6 +1112,17 @@ void CallTraceMethod(JSTracer* trc, JSObject* obj) {
obj->as<ObjectSubclass>().trace(trc); obj->as<ObjectSubclass>().trace(trc);
} }
#ifdef JS_HAS_CTYPES
namespace ctypes {
extern size_t SizeOfDataIfCDataObject(mozilla::MallocSizeOf mallocSizeOf,
JSObject* obj);
} // namespace ctypes
#endif
} /* namespace js */ } /* namespace js */
#endif /* vm_JSObject_h */ #endif /* vm_JSObject_h */

Просмотреть файл

@ -414,7 +414,7 @@ struct JSRuntime {
js::MainThreadData<js::ScriptEnvironmentPreparer*> scriptEnvironmentPreparer; js::MainThreadData<js::ScriptEnvironmentPreparer*> scriptEnvironmentPreparer;
js::MainThreadData<js::CTypesActivityCallback> ctypesActivityCallback; js::MainThreadData<JS::CTypesActivityCallback> ctypesActivityCallback;
private: private:
js::WriteOnceData<const JSClass*> windowProxyClass_; js::WriteOnceData<const JSClass*> windowProxyClass_;

Просмотреть файл

@ -33,7 +33,7 @@ static char* UnicodeToNative(JSContext* cx, const char16_t* source,
return result; return result;
} }
static JSCTypesCallbacks sCallbacks = {UnicodeToNative}; static JS::CTypesCallbacks sCallbacks = {UnicodeToNative};
NS_IMPL_ISUPPORTS(Module, nsIXPCScriptable) NS_IMPL_ISUPPORTS(Module, nsIXPCScriptable)
@ -66,13 +66,13 @@ static bool SealObjectAndPrototype(JSContext* cx, JS::Handle<JSObject*> parent,
static bool InitAndSealCTypesClass(JSContext* cx, static bool InitAndSealCTypesClass(JSContext* cx,
JS::Handle<JSObject*> global) { JS::Handle<JSObject*> global) {
// Init the ctypes object. // Init the ctypes object.
if (!JS_InitCTypesClass(cx, global)) return false; if (!JS::InitCTypesClass(cx, global)) return false;
// Set callbacks for charset conversion and such. // Set callbacks for charset conversion and such.
JS::Rooted<JS::Value> ctypes(cx); JS::Rooted<JS::Value> ctypes(cx);
if (!JS_GetProperty(cx, global, "ctypes", &ctypes)) return false; if (!JS_GetProperty(cx, global, "ctypes", &ctypes)) return false;
JS_SetCTypesCallbacks(ctypes.toObjectOrNull(), &sCallbacks); JS::SetCTypesCallbacks(ctypes.toObjectOrNull(), &sCallbacks);
// Seal up Object, Function, Array and Error and their prototypes. (This // Seal up Object, Function, Array and Error and their prototypes. (This
// single object instance is shared amongst everyone who imports the ctypes // single object instance is shared amongst everyone who imports the ctypes