Differential D3094 Diff 14018 ps/trunk/libraries/source/spidermonkey/include-win32-debug/js/Initialization.h
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/libraries/source/spidermonkey/include-win32-debug/js/Initialization.h
Show All 19 Lines | |||||
* that should happen only once across all runtimes. It's an API requirement | * that should happen only once across all runtimes. It's an API requirement | ||||
* that JS_Init (and JS_ShutDown, if called) be called in a thread-aware | * that JS_Init (and JS_ShutDown, if called) be called in a thread-aware | ||||
* manner, so this (internal -- embedders, don't use!) variable doesn't need to | * manner, so this (internal -- embedders, don't use!) variable doesn't need to | ||||
* be atomic. | * be atomic. | ||||
*/ | */ | ||||
extern JS_PUBLIC_DATA(InitState) | extern JS_PUBLIC_DATA(InitState) | ||||
libraryInitState; | libraryInitState; | ||||
extern JS_PUBLIC_API(const char*) | |||||
InitWithFailureDiagnostic(bool isDebugBuild); | |||||
} // namespace detail | } // namespace detail | ||||
} // namespace JS | } // namespace JS | ||||
// These are equivalent to ICU's |UMemAllocFn|, |UMemReallocFn|, and | // These are equivalent to ICU's |UMemAllocFn|, |UMemReallocFn|, and | ||||
// |UMemFreeFn| types. The first argument (called |context| in the ICU docs) | // |UMemFreeFn| types. The first argument (called |context| in the ICU docs) | ||||
// will always be nullptr and should be ignored. | // will always be nullptr and should be ignored. | ||||
typedef void* (*JS_ICUAllocFn)(const void*, size_t size); | typedef void* (*JS_ICUAllocFn)(const void*, size_t size); | ||||
typedef void* (*JS_ICUReallocFn)(const void*, void* p, size_t size); | typedef void* (*JS_ICUReallocFn)(const void*, void* p, size_t size); | ||||
Show All 17 Lines | |||||
* This method must be called before any other JSAPI method is used on any | * This method must be called before any other JSAPI method is used on any | ||||
* thread. Once it has been used, it is safe to call any JSAPI method, and it | * thread. Once it has been used, it is safe to call any JSAPI method, and it | ||||
* remains safe to do so until JS_ShutDown is correctly called. | * remains safe to do so until JS_ShutDown is correctly called. | ||||
* | * | ||||
* It is currently not possible to initialize SpiderMonkey multiple times (that | * It is currently not possible to initialize SpiderMonkey multiple times (that | ||||
* is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so | * is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so | ||||
* again). This restriction may eventually be lifted. | * again). This restriction may eventually be lifted. | ||||
*/ | */ | ||||
extern JS_PUBLIC_API(bool) | inline bool | ||||
JS_Init(void); | JS_Init(void) | ||||
{ | |||||
#ifdef DEBUG | |||||
return !JS::detail::InitWithFailureDiagnostic(true); | |||||
#else | |||||
return !JS::detail::InitWithFailureDiagnostic(false); | |||||
#endif | |||||
} | |||||
/** | |||||
* A variant of JS_Init. On success it returns nullptr. On failure it returns a | |||||
* pointer to a string literal that describes how initialization failed, which | |||||
* can be useful for debugging purposes. | |||||
*/ | |||||
inline const char* | |||||
JS_InitWithFailureDiagnostic(void) | |||||
{ | |||||
#ifdef DEBUG | |||||
return JS::detail::InitWithFailureDiagnostic(true); | |||||
#else | |||||
return JS::detail::InitWithFailureDiagnostic(false); | |||||
#endif | |||||
} | |||||
/* | |||||
* Returns true if SpiderMonkey has been initialized successfully, even if it has | |||||
* possibly been shut down. | |||||
* | |||||
* Note that it is the responsibility of the embedder to call JS_Init() and | |||||
* JS_ShutDown() at the correct times, and therefore this API should ideally not | |||||
* be necessary to use. This is only intended to be used in cases where the | |||||
* embedder isn't in full control of deciding whether to initialize SpiderMonkey | |||||
* or hand off the task to another consumer. | |||||
*/ | |||||
inline bool | |||||
JS_IsInitialized(void) | |||||
{ | |||||
return JS::detail::libraryInitState != JS::detail::InitState::Uninitialized; | |||||
} | |||||
/** | /** | ||||
* Destroy free-standing resources allocated by SpiderMonkey, not associated | * Destroy free-standing resources allocated by SpiderMonkey, not associated | ||||
* with any runtime, context, or other structure. | * with any runtime, context, or other structure. | ||||
* | * | ||||
* This method should be called after all other JSAPI data has been properly | * This method should be called after all other JSAPI data has been properly | ||||
* cleaned up: every new runtime must have been destroyed, every new context | * cleaned up: every new runtime must have been destroyed, every new context | ||||
* must have been destroyed, and so on. Calling this method before all other | * must have been destroyed, and so on. Calling this method before all other | ||||
Show All 14 Lines |
Wildfire Games · Phabricator