JSAPI Reference

  • Revision slug: SpiderMonkey/JSAPI_Reference/JSAPI_Reference
  • Revision title: JSAPI Reference
  • Revision id: 147887
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment /* Functions */ Strings

Revision Content

The JSAPI is the C API for the SpiderMonkey JavaScript engine. To learn how to use the JSAPI, see Embedding SpiderMonkey and the JSAPI Phrasebook.


Alphabetical List

Data Structures

Callback Types

Native function types:

JSClass method types:

JSExtendedClass method types:

JSObjectOps method types:

JSXMLObjectOps method types:

JSLocaleCallback method types:

Other callback types:

Functions

Memory management

These functions act like the Standard C malloc family of functions, except that errors are reported using the SpiderMonkey error APIs rather than errno:

JavaScript objects, strings, and floating-point numbers are garbage collected. These functions provide access to the garbage collector:

The rest of these APIs help protect objects from being destroyed by the garbage collector before the application is done using them.

If a variable is a root, then anything it points to will not be freed by the garbage collector. Failure to root objects is a very common cause of mysterious crashes.

Local root scopes are another way of protecting objects from the garbage collector.

Miscellaneous GC APIs:

Strings

Interning strings tells the SpiderMonkey engine to reuse existing string objects when possible.

The character data for external strings is stored in memory provided by the application. Applications can use this to avoid copying data back and forth between SpiderMonkey's heap and application memory.


Properties

Arrays

Error handling

The following functions allow C/C++ functions to throw and catch JavaScript exceptions:

Threading

The following functions support the SpiderMonkey threading model. They are only available in JS_THREADSAFE builds.

Macros

Deprecated

Preprocessor conditionals

{{ wiki.languages( { "ja": "ja/JSAPI_Reference", "pl": "pl/Dokumentacja_JSAPI" } ) }}

Revision Source

<p>
The <b>JSAPI</b> is the C API for the <a href="en/SpiderMonkey">SpiderMonkey</a> JavaScript engine. To learn how to use the JSAPI, see <a href="en/Embedding_SpiderMonkey">Embedding SpiderMonkey</a> and the <a href="en/JSAPI_Phrasebook">JSAPI Phrasebook</a>.
</p><p><br>
<a href="en/JSAPI_Reference/Alphabetical_List">Alphabetical List</a>
</p>
<h3 name="Data_Structures"> Data Structures </h3>
<ul><li> <a href="en/JSClass">JSClass</a>
</li><li> <a href="en/JSConstDoubleSpec">JSConstDoubleSpec</a>	 
</li><li> <a href="en/JSErrorReport">JSErrorReport</a>
</li><li> <a href="en/JSExceptionState">JSExceptionState</a>
</li><li> <a href="en/JSExtendedClass">JSExtendedClass</a>
</li><li> <a href="en/JSFunctionSpec">JSFunctionSpec</a>
</li><li> <a href="en/JSIdArray">JSIdArray</a>
</li><li> <a href="en/JSLocaleCallbacks">JSLocaleCallbacks</a>
</li><li> <a href="en/JSObjectOps">JSObjectOps</a>
</li><li> <a href="en/JSPrincipals">JSPrincipals</a>
</li><li> <a href="en/JSProperty">JSProperty</a>
</li><li> <a href="en/JSPropertySpec">JSPropertySpec</a>
</li><li> <a href="en/JSXMLObjectOps">JSXMLObjectOps</a>
</li></ul>
<h3 name="Callback_Types"> Callback Types </h3>
<p>Native function types:
</p>
<ul><li> <a href="en/JSNative">JSNative</a>
</li><li> <a href="en/JSFastNative">JSFastNative</a>
</li></ul>
<p><a href="en/JSClass">JSClass</a> method types:
</p>
<ul><li> <a href="en/JSPropertyOp">JSPropertyOp</a>
</li><li> <a href="en/JSEnumerateOp">JSEnumerateOp</a>
</li><li> <a href="en/JSResolveOp">JSResolveOp</a>
</li><li> <a href="en/JSNewResolveOp">JSNewResolveOp</a>
</li><li> <a href="en/JSConvertOp">JSConvertOp</a>
</li><li> <a href="en/JSFinalizeOp">JSFinalizeOp</a>
</li><li> <a href="en/JSGetObjectOps">JSGetObjectOps</a>
</li><li> <a href="en/JSCheckAccessOp">JSCheckAccessOp</a>
</li><li> <a href="en/JSXDRObjectOp">JSXDRObjectOp</a>
</li><li> <a href="en/JSHasInstanceOp">JSHasInstanceOp</a>
</li><li> <a href="en/JSMarkOp">JSMarkOp</a>
</li><li> <a href="en/JSReserveSlotsOp">JSReserveSlotsOp</a>
</li></ul>
<p><a href="en/JSExtendedClass">JSExtendedClass</a> method types:
</p>
<ul><li> <a href="en/JSIteratorOp">JSIteratorOp</a>
</li><li> <a href="en/JSEqualityOp">JSEqualityOp</a>
</li><li> <a href="en/JSObjectOp">JSObjectOp</a>
</li></ul>
<p><a href="en/JSObjectOps">JSObjectOps</a> method types:
</p>
<ul><li> <a href="en/JSNewObjectMapOp">JSNewObjectMapOp</a>
</li><li> <a href="en/JSObjectMapOp">JSObjectMapOp</a>
</li><li> <a href="en/JSLookupPropOp">JSLookupPropOp</a>
</li><li> <a href="en/JSDefinePropOp">JSDefinePropOp</a>
</li><li> <a href="en/JSPropertyIdOp">JSPropertyIdOp</a>
</li><li> <a href="en/JSAttributesOp">JSAttributesOp</a>
</li><li> <a href="en/JSConvertOp">JSConvertOp</a>
</li><li> <a href="en/JSNewEnumerateOp">JSNewEnumerateOp</a>
</li><li> <a href="en/JSCheckAccessIdOp">JSCheckAccessIdOp</a>
</li><li> <a href="en/JSObjectOp">JSObjectOp</a>
</li><li> <a href="en/JSPropertyRefOp">JSPropertyRefOp</a>
</li><li> <a href="en/JSXDRObjectOp">JSXDRObjectOp</a>
</li><li> <a href="en/JSHasInstanceOp">JSHasInstanceOp</a>
</li><li> <a href="en/JSSetObjectSlotOp">JSSetObjectSlotOp</a>
</li><li> <a href="en/JSTraceOp">JSTraceOp</a>
</li><li> <a href="en/JSFinalizeOp">JSFinalizeOp</a>
</li><li> <a href="en/JSGetRequiredSlotOp">JSGetRequiredSlotOp</a>
</li><li> <a href="en/JSSetRequiredSlotOp">JSSetRequiredSlotOp</a>
</li></ul>
<p><a href="en/JSXMLObjectOps">JSXMLObjectOps</a> method types:
</p>
<ul><li> <a href="en/JSGetMethodOp">JSGetMethodOp</a>
</li><li> <a href="en/JSSetMethodOp">JSSetMethodOp</a>
</li><li> <a href="en/JSEnumerateValuesOp">JSEnumerateValuesOp</a>
</li><li> <a href="en/JSEqualityOp">JSEqualityOp</a>
</li><li> <a href="en/JSConcatenateOp">JSConcatenateOp</a>
</li></ul>
<p><a href="en/JSLocaleCallback">JSLocaleCallback</a> method types:
</p>
<ul><li> <a href="en/JSLocaleToUpperCase">JSLocaleToUpperCase</a>
</li><li> <a href="en/JSLocaleToLowerCase">JSLocaleToLowerCase</a>
</li><li> <a href="en/JSLocaleCompare">JSLocaleCompare</a>
</li><li> <a href="en/JSLocaleToUnicode">JSLocaleToUnicode</a>
</li><li> <a href="en/JSErrorCallback">JSErrorCallback</a>
</li></ul>
<p>Other callback types:
</p>
<ul><li> <a href="en/JSStringFinalizeOp">JSStringFinalizeOp</a> - used by <a href="en/JS_AddExternalStringFinalizer">JS_AddExternalStringFinalizer</a>
</li><li> <a href="en/JSTraceCallback">JSTraceCallback</a> - used by <a href="en/JS_TRACER_INIT">JS_TRACER_INIT</a>
</li><li> <a href="en/JSTraceNamePrinter">JSTraceNamePrinter</a> - used by <a href="en/JS_SET_TRACING_DETAILS">JS_SET_TRACING_DETAILS</a>
</li><li> <a href="en/JSContextCallback">JSContextCallback</a> - used by <a href="en/JS_SetContextCallback">JS_SetContextCallback</a>
</li><li> <a href="en/JSGCCallback">JSGCCallback</a> - used by <a href="en/JS_SetGCCallback">JS_SetGCCallback</a>
</li><li> <a href="en/JSTraceDataOp">JSTraceDataOp</a> - used by <a href="en/JS_SetExtraGCRoots">JS_SetExtraGCRoots</a>
</li><li> <a href="en/JSBranchCallback">JSBranchCallback</a> - used by <a href="en/JS_SetBranchCallback">JS_SetBranchCallback</a>
</li><li> <a href="en/JSErrorReporter">JSErrorReporter</a> - used by <a href="en/JS_SetErrorReporter">JS_SetErrorReporter</a>
</li><li> <a href="en/JSErrorCallback">JSErrorCallback</a> - used by <a href="en/JS_ReportErrorNumber">JS_ReportErrorNumber</a> and friends
</li><li> <a href="en/JSArgumentFormatter">JSArgumentFormatter</a> - used by <a href="en/JS_AddArgumentFormatter">JS_AddArgumentFormatter</a>
</li><li> <a href="en/JSPrincipalsTranscoder">JSPrincipalsTranscoder</a> - used by <a href="en/JS_SetPrincipalsTranscoder">JS_SetPrincipalsTranscoder</a>
</li><li> <a href="en/JSObjectPrincipalsFinder">JSObjectPrincipalsFinder</a> - used by <a href="en/JS_SetObjectPrincipalsFinder">JS_SetObjectPrincipalsFinder</a>
</li><li> <a href="en/JSGCRootMapFun">JSGCRootMapFun</a> - used by <a href="en/JS_MapGCRoots">JS_MapGCRoots</a>
</li></ul>
<h3 name="Functions"> Functions </h3>
<ul><li> <a href="en/JS_AddArgumentFormatter">JS_AddArgumentFormatter</a>
</li><li> <a href="en/JS_BufferIsCompilableUnit">JS_BufferIsCompilableUnit</a>
</li><li> <a href="en/JS_CallFunction">JS_CallFunction</a>
</li><li> <a href="en/JS_CallFunctionName">JS_CallFunctionName</a>
</li><li> <a href="en/JS_CallFunctionValue">JS_CallFunctionValue</a>
</li><li> <a href="en/JS_CheckAccess">JS_CheckAccess</a>
</li><li> <a href="en/JS_ClearNewbornRoots">JS_ClearNewbornRoots</a>
</li><li> <a href="en/JS_ClearRegExpRoots">JS_ClearRegExpRoots</a>
</li><li> <a href="en/JS_ClearRegExpStatics">JS_ClearRegExpStatics</a>
</li><li> <a href="en/JS_ClearScope">JS_ClearScope</a>
</li><li> <a href="en/JS_CloneFunctionObject">JS_CloneFunctionObject</a>
</li><li> <a href="en/JS_CompileFile">JS_CompileFile</a>
</li><li> <a href="en/JS_CompileFileHandle">JS_CompileFileHandle</a>
</li><li> <a href="en/JS_CompileFileHandleForPrincipals">JS_CompileFileHandleForPrincipals</a>
</li><li> <a href="en/JS_CompileFunction">JS_CompileFunction</a>
</li><li> <a href="en/JS_CompileFunctionForPrincipals">JS_CompileFunctionForPrincipals</a>
</li><li> <a href="en/JS_CompileScript">JS_CompileScript</a>
</li><li> <a href="en/JS_CompileScriptForPrincipals">JS_CompileScriptForPrincipals</a>
</li><li> <a href="en/JS_CompileUCFunction">JS_CompileUCFunction</a>
</li><li> <a href="en/JS_CompileUCFunctionForPrincipals">JS_CompileUCFunctionForPrincipals</a>
</li><li> <a href="en/JS_CompileUCScript">JS_CompileUCScript</a>
</li><li> <a href="en/JS_CompileUCScriptForPrincipals">JS_CompileUCScriptForPrincipals</a>
</li><li> <a href="en/JS_ConstructObject">JS_ConstructObject</a>
</li><li> <a href="en/JS_ConstructObjectWithArguments">JS_ConstructObjectWithArguments</a>
</li><li> <a href="en/JS_ContextIterator">JS_ContextIterator</a>
</li><li> <a href="en/JS_ConvertArguments">JS_ConvertArguments</a>
</li><li> <a href="en/JS_ConvertArgumentsVA">JS_ConvertArgumentsVA</a>
</li><li> <a href="en/JS_ConvertStub">JS_ConvertStub</a>
</li><li> <a href="en/JS_ConvertValue">JS_ConvertValue</a>
</li><li> <a href="en/JS_DecodeBytes">JS_DecodeBytes</a>
</li><li> <a href="en/JS_DecompileFunction">JS_DecompileFunction</a>
</li><li> <a href="en/JS_DecompileFunctionBody">JS_DecompileFunctionBody</a>
</li><li> <a href="en/JS_DecompileScript">JS_DecompileScript</a>
</li><li> <a href="en/JS_DefineConstDoubles">JS_DefineConstDoubles</a>
</li><li> <a href="en/JS_DefineFunction">JS_DefineFunction</a>
</li><li> <a href="en/JS_DefineFunctions">JS_DefineFunctions</a>
</li><li> <a href="en/JS_DefineObject">JS_DefineObject</a>
</li><li> <a href="en/JS_DefineUCFunction">JS_DefineUCFunction</a>
</li><li> <a href="en/JS_DestroyContext">JS_DestroyContext</a>
</li><li> <a href="en/JS_DestroyContextMaybeGC">JS_DestroyContextMaybeGC</a>
</li><li> <a href="en/JS_DestroyContextNoGC">JS_DestroyContextNoGC</a>
</li><li> <a href="en/JS_DestroyIdArray">JS_DestroyIdArray</a>
</li><li> <a href="en/JS_DestroyRuntime">JS_DestroyRuntime</a>
</li><li> <a href="en/JS_DestroyScript">JS_DestroyScript</a>
</li><li> <a href="en/JS_DropPrincipals">JS_DropPrincipals</a>
</li><li> <a href="en/JS_EncodeCharacters">JS_EncodeCharacters</a>
</li><li> <a href="en/JS_EnumerateStandardClasses">JS_EnumerateStandardClasses</a>
</li><li> <a href="en/JS_EnumerateStub">JS_EnumerateStub</a>
</li><li> <a href="en/JS_EnumerateResolvedStandardClasses">JS_EnumerateResolvedStandardClasses</a>
</li><li> <a href="en/JS_EvaluateScript">JS_EvaluateScript</a>
</li><li> <a href="en/JS_EvaluateScriptForPrincipals">JS_EvaluateScriptForPrincipals</a>
</li><li> <a href="en/JS_EvaluateUCScript">JS_EvaluateUCScript</a>
</li><li> <a href="en/JS_EvaluateUCScriptForPrincipals">JS_EvaluateUCScriptForPrincipals</a>
</li><li> <a href="en/JS_ExecuteScript">JS_ExecuteScript</a>
</li><li> <a href="en/JS_ExecuteScriptPart">JS_ExecuteScriptPart</a>
</li><li> <a href="en/JS_FinalizeStub">JS_FinalizeStub</a>
</li><li> <a href="en/JS_Finish">JS_Finish</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_GetClass">JS_GetClass</a>
</li><li> <a href="en/JS_GetClassObject">JS_GetClassObject</a>
</li><li> <a href="en/JS_GetConstructor">JS_GetConstructor</a>
</li><li> <a href="en/JS_GetContextPrivate">JS_GetContextPrivate</a>
</li><li> <a href="en/JS_GetFunctionArity">JS_GetFunctionArity</a>
</li><li> <a href="en/JS_GetFunctionFlags">JS_GetFunctionFlags</a>
</li><li> <a href="en/JS_GetFunctionId">JS_GetFunctionId</a>
</li><li> <a href="en/JS_GetFunctionName">JS_GetFunctionName</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_GetFunctionObject">JS_GetFunctionObject</a>
</li><li> <a href="en/JS_GetGlobalObject">JS_GetGlobalObject</a>
</li><li> <a href="en/JS_GetImplementationVersion">JS_GetImplementationVersion</a>
</li><li> <a href="en/JS_GetInstancePrivate">JS_GetInstancePrivate</a>
</li><li> <a href="en/JS_GetLocaleCallbacks">JS_GetLocaleCallbacks</a>
</li><li> <a href="en/JS_GetMethod">JS_GetMethod</a>
</li><li> <a href="en/JS_GetNaNValue">JS_GetNaNValue</a>
</li><li> <a href="en/JS_GetNegativeInfinityValue">JS_GetNegativeInfinityValue</a>
</li><li> <a href="en/JS_GetObjectId">JS_GetObjectId</a>
</li><li> <a href="en/JS_GetOptions">JS_GetOptions</a>
</li><li> <a href="en/JS_GetParent">JS_GetParent</a>
</li><li> <a href="en/JS_GetPositiveInfinityValue">JS_GetPositiveInfinityValue</a>	 
</li><li> <a href="en/JS_GetPrivate">JS_GetPrivate</a>
</li><li> <a href="en/JS_GetPrototype">JS_GetPrototype</a>
</li><li> <a href="en/JS_GetReservedSlot">JS_GetReservedSlot</a>
</li><li> <a href="en/JS_GetRuntime">JS_GetRuntime</a>
</li><li> <a href="en/JS_GetRuntimePrivate">JS_GetRuntimePrivate</a>
</li><li> <a href="en/JS_GetScopeChain">JS_GetScopeChain</a>
</li><li> <a href="en/JS_GetScriptObject">JS_GetScriptObject</a>
</li><li> <a href="en/JS_GetTypeName">JS_GetTypeName</a>
</li><li> <a href="en/JS_GetVersion">JS_GetVersion</a>
</li><li> <a href="en/JS_HasInstance">JS_HasInstance</a>
</li><li> <a href="en/JS_HoldPrincipals">JS_HoldPrincipals</a>
</li><li> <a href="en/JS_IdToValue">JS_IdToValue</a>
</li><li> <a href="en/JS_Init">JS_Init</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_InitClass">JS_InitClass</a>
</li><li> <a href="en/JS_InitStandardClasses">JS_InitStandardClasses</a>
</li><li> <a href="en/JS_InstanceOf">JS_InstanceOf</a>
</li><li> <a href="en/JS_IsAboutToBeFinalized">JS_IsAboutToBeFinalized</a>
</li><li> <a href="en/JS_IsAssigning">JS_IsAssigning</a>
</li><li> <a href="en/JS_IsConstructing">JS_IsConstructing</a>
</li><li> <a href="en/JS_IsRunning">JS_IsRunning</a>
</li><li> <a href="en/JS_Lock">JS_Lock</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_LockRuntime">JS_LockRuntime</a>
</li><li> <a href="en/JS_NewContext">JS_NewContext</a>
</li><li> <a href="en/JS_NewDouble">JS_NewDouble</a>
</li><li> <a href="en/JS_NewDoubleValue">JS_NewDoubleValue</a>
</li><li> <a href="en/JS_NewFunction">JS_NewFunction</a>
</li><li> <a href="en/JS_NewIdArray">JS_NewIdArray</a>
</li><li> <a href="en/JS_NewNumberValue">JS_NewNumberValue</a>
</li><li> <a href="en/JS_NewObject">JS_NewObject</a>
</li><li> <a href="en/JS_NewRegExpObject">JS_NewRegExpObject</a>
</li><li> <a href="en/JS_NewRuntime">JS_NewRuntime</a>
</li><li> <a href="en/JS_NewRegExpObject">JS_NewRegExpObject</a>
</li><li> <a href="en/JS_NewScriptObject">JS_NewScriptObject</a>
</li><li> <a href="en/JS_NewURegExpObject">JS_NewRegExpObject</a>
</li><li> <a href="en/JS_Now">JS_Now</a>
</li><li> <a href="en/JS_ObjectIsFunction">JS_ObjectIsFunction</a>
</li><li> <a href="en/JS_PopArguments">JS_PopArguments</a>
</li><li> <a href="en/JS_PropertyStub">JS_PropertyStub</a>
</li><li> <a href="en/JS_PushArguments">JS_PushArguments</a>
</li><li> <a href="en/JS_PushArgumentsVA">JS_PushArgumentsVA</a>
</li><li> <a href="en/JS_RemoveArgumentFormatter">JS_RemoveArgumentFormatter</a>
</li><li> <a href="en/JS_ResolveStandardClass">JS_ResolveStandardClass</a>
</li><li> <a href="en/JS_ResolveStub">JS_ResolveStub</a>
</li><li> <a href="en/JS_SealObject">JS_SealObject</a>
</li><li> <a href="en/JS_SetBranchCallback">JS_SetBranchCallback</a>
</li><li> <a href="en/JS_SetCallReturnValue2">JS_SetCallReturnValue2</a>
</li><li> <a href="en/JS_SetCheckObjectAccessCallback">JS_SetCheckObjectAccessCallback</a>
</li><li> <a href="en/JS_SetContextPrivate">JS_SetContextPrivate</a>
</li><li> <a href="en/JS_SetErrorReporter">JS_SetErrorReporter</a>
</li><li> <a href="en/JS_SetGlobalObject">JS_SetGlobalObject</a>
</li><li> <a href="en/JS_SetLocaleCallbacks">JS_SetLocaleCallbacks</a>
</li><li> <a href="en/JS_SetObjectPrincipalsFinder">JS_SetObjectPrincipalsFinder</a>
</li><li> <a href="en/JS_SetOptions">JS_SetOptions</a>
</li><li> <a href="en/JS_SetParent">JS_SetParent</a>
</li><li> <a href="en/JS_SetPrincipalsTranscoder">JS_SetPrincipalsTranscoder</a>
</li><li> <a href="en/JS_SetPrivate">JS_SetPrivate</a>
</li><li> <a href="en/JS_SetPrototype">JS_SetPrototype</a>
</li><li> <a href="en/JS_SetRegExpInput">JS_SetRegExpInput</a>
</li><li> <a href="en/JS_SetThreadStackLimit">JS_SetThreadStackLimit</a>
</li><li> <a href="en/JS_SetRegExpInput">JS_SetRegExpInput</a>
</li><li> <a href="en/JS_SetReservedSlot">JS_SetReservedSlot</a>
</li><li> <a href="en/JS_SetRuntimePrivate">JS_SetRuntimePrivate</a>
</li><li> <a href="en/JS_SetVersion">JS_SetVersion</a>
</li><li> <a href="en/JS_ShutDown">JS_ShutDown</a>
</li><li> <a href="en/JS_StringToVersion">JS_StringToVersion</a>
</li><li> <a href="en/JS_ToggleOptions">JS_ToggleOptions</a>
</li><li> <a href="en/JS_ThrowReportedError">JS_ThrowReportedError</a>
</li><li> <a href="en/JS_TypeOfValue">JS_TypeOfValue</a>
</li><li> <a href="en/JS_Unlock">JS_Unlock</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_UnlockRuntime">JS_UnlockRuntime</a>
</li><li> <a href="en/JS_ValueToBoolean">JS_ValueToBoolean</a>
</li><li> <a href="en/JS_ValueToConstructor">JS_ValueToConstructor</a>
</li><li> <a href="en/JS_ValueToECMAInt32">JS_ValueToECMAInt32</a>
</li><li> <a href="en/JS_ValueToECMAUint32">JS_ValueToECMAUint32</a>
</li><li> <a href="en/JS_ValueToFunction">JS_ValueToFunction</a>
</li><li> <a href="en/JS_ValueToId">JS_ValueToId</a>
</li><li> <a href="en/JS_ValueToInt32">JS_ValueToInt32</a>
</li><li> <a href="en/JS_ValueToNumber">JS_ValueToNumber</a>
</li><li> <a href="en/JS_ValueToObject">JS_ValueToObject</a>
</li><li> <a href="en/JS_ValueToString">JS_ValueToString</a>
</li><li> <a href="en/JS_ValueToUint16">JS_ValueToUint16</a>
</li><li> <a href="en/JS_VersionToString">JS_VersionToString</a>
</li></ul>
<h4 name="Memory_management"> Memory management </h4>
<p>These functions act like the Standard C <code>malloc</code> family of functions, except that errors are reported using the SpiderMonkey error APIs rather than <code>errno</code>:
</p>
<ul><li> <a href="en/JS_malloc">JS_malloc</a>
</li><li> <a href="en/JS_free">JS_free</a>
</li><li> <a href="en/JS_realloc">JS_realloc</a>
</li><li> <a href="en/JS_strdup">JS_strdup</a>
</li></ul>
<p>JavaScript objects, strings, and floating-point numbers are garbage collected.  These functions provide access to the garbage collector:
</p>
<ul><li> <a href="en/JS_GC">JS_GC</a>
</li><li> <a href="en/JS_MaybeGC">JS_MaybeGC</a>
</li><li> <a href="en/JS_SetGCParameter">JS_SetGCParameter</a>
</li><li> <a href="en/JS_SetGCCallback">JS_SetGCCallback</a>
</li><li> <a href="en/JS_SetGCCallbackRT">JS_SetGCCallbackRT</a>
</li><li> <a href="en/JS_MarkGCThing">JS_MarkGCThing</a>
</li><li> <a href="en/JS_DumpHeap">JS_DumpHeap</a> {{template.Jsapi_minversion_inline(1.9)}}
</li></ul>
<p>The rest of these APIs help protect objects from being destroyed by the garbage collector before the application is done using them.
</p><p>If a variable is a <i>root</i>, then anything it points to will not be freed by the garbage collector.  Failure to root objects is a very common cause of mysterious crashes.
</p>
<ul><li> <a href="en/JS_AddRoot">JS_AddRoot</a>
</li><li> <a href="en/JS_AddNamedRoot">JS_AddNamedRoot</a>
</li><li> <a href="en/JS_AddNamedRootRT">JS_AddNamedRootRT</a>
</li><li> <a href="en/JS_RemoveRoot">JS_RemoveRoot</a>
</li><li> <a href="en/JS_RemoveRootRT">JS_RemoveRootRT</a>
</li><li> <a href="en/JS_MapGCRoots">JS_MapGCRoots</a>
</li><li> <a href="en/JS_DumpNamedRoots">JS_DumpNamedRoots</a>
</li></ul>
<p>Local root scopes are another way of protecting objects from the garbage collector.
</p>
<ul><li> <a href="en/JS_EnterLocalRootScope">JS_EnterLocalRootScope</a>
</li><li> <a href="en/JS_LeaveLocalRootScope">JS_LeaveLocalRootScope</a>
</li><li> <a href="en/JS_LeaveLocalRootScopeWithResult">JS_LeaveLocalRootScopeWithResult</a>
</li><li> <a href="en/JS_ForgetLocalRoot">JS_ForgetLocalRoot</a>
</li></ul>
<p>Miscellaneous GC APIs:
</p>
<ul><li> <a href="en/JS_LockGCThing">JS_LockGCThing</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_LockGCThingRT">JS_LockGCThingRT</a>
</li><li> <a href="en/JS_UnlockGCThing">JS_UnlockGCThing</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_UnlockGCThingRT">JS_UnlockGCThingRT</a>
</li></ul>
<h4 name="Strings"> Strings </h4>
<ul><li> <a href="en/JS_NewString">JS_NewString</a>
</li><li> <a href="en/JS_NewStringCopyN">JS_NewStringCopyN</a>
</li><li> <a href="en/JS_NewStringCopyZ">JS_NewStringCopyZ</a>
</li><li> <a href="en/JS_NewUCString">JS_NewUCString</a>
</li><li> <a href="en/JS_NewUCStringCopyN">JS_NewUCStringCopyN</a>
</li><li> <a href="en/JS_NewUCStringCopyZ">JS_NewUCStringCopyZ</a>
</li><li> <a href="en/JS_NewGrowableString">JS_NewGrowableString</a>
</li><li> <a href="en/JS_NewDependentString">JS_NewDependentString</a>
</li><li> <a href="en/JS_GetEmptyStringValue">JS_GetEmptyStringValue</a>
</li><li> <a href="en/JS_CompareStrings">JS_CompareStrings</a>
</li><li> <a href="en/JS_ConcatStrings">JS_ConcatStrings</a>
</li><li> <a href="en/JS_GetStringBytes">JS_GetStringBytes</a>
</li><li> <a href="en/JS_GetStringChars">JS_GetStringChars</a>
</li><li> <a href="en/JS_GetStringLength">JS_GetStringLength</a>
</li><li> <a href="en/JS_MakeStringImmutable">JS_MakeStringImmutable</a>
</li><li> <a href="en/JS_UndependString">JS_UndependString</a>
</li></ul>
<ul><li> <a href="en/JS_StringsAreUTF8">JS_StringsAreUTF8</a>
</li></ul>
<p><i>Interning</i> strings tells the SpiderMonkey engine to reuse existing string objects when possible.
</p>
<ul><li> <a href="en/JS_InternString">JS_InternString</a>
</li><li> <a href="en/JS_InternUCString">JS_InternUCString</a>
</li><li> <a href="en/JS_InternUCStringN">JS_InternUCStringN</a>
</li></ul>
<p>The character data for <i>external strings</i> is stored in memory provided by the application.  Applications can use this to avoid copying data back and forth between SpiderMonkey's heap and application memory.
</p>
<ul><li> <a href="en/JS_AddExternalStringFinalizer">JS_AddExternalStringFinalizer</a>
</li><li> <a href="en/JS_RemoveExternalStringFinalizer">JS_RemoveExternalStringFinalizer</a>
</li><li> <a href="en/JS_GetExternalStringGCType">JS_GetExternalStringGCType</a>
</li><li> <a href="en/JS_NewExternalString">JS_NewExternalString</a>
</li></ul>
<p><br>
</p>
<h4 name="Properties"> Properties </h4>
<ul><li> <a href="en/JS_AlreadyHasOwnProperty">JS_AlreadyHasOwnProperty</a> {{template.Jsapi_minversion_inline(1.9)}}
</li><li> <a href="en/JS_DefineProperties">JS_DefineProperties</a>
</li><li> <a href="en/JS_DefineProperty">JS_DefineProperty</a>
</li><li> <a href="en/JS_DefinePropertyWithTinyId">JS_DefinePropertyWithTinyId</a>
</li><li> <a href="en/JS_DefineUCProperty">JS_DefineUCProperty</a>
</li><li> <a href="en/JS_DefineUCPropertyWithTinyID">JS_DefineUCPropertyWithTinyID</a>
</li><li> <a href="en/JS_DeleteProperty">JS_DeleteProperty</a>
</li><li> <a href="en/JS_DeleteProperty2">JS_DeleteProperty2</a>
</li><li> <a href="en/JS_DeleteUCProperty2">JS_DeleteUCProperty2</a>
</li><li> <a href="en/JS_Enumerate">JS_Enumerate</a>
</li><li> <a href="en/JS_GetProperty">JS_GetProperty</a>
</li><li> <a href="en/JS_GetPropertyAttributes">JS_GetPropertyAttributes</a>
</li><li> <a href="en/JS_GetPropertyAttrsGetterAndSetter">JS_GetPropertyAttrsGetterAndSetter</a>
</li><li> <a href="en/JS_GetUCProperty">JS_GetUCProperty</a>
</li><li> <a href="en/JS_GetUCPropertyAttributes">JS_GetUCPropertyAttributes</a>
</li><li> <a href="en/JS_GetUCPRopertyAttrsGetterAndSetter">JS_GetUCPRopertyAttrsGetterAndSetter</a>
</li><li> <a href="en/JS_HasProperty">JS_HasProperty</a>
</li><li> <a href="en/JS_HasUCProperty">JS_HasUCProperty</a>
</li><li> <a href="en/JS_LookupProperty">JS_LookupProperty</a>
</li><li> <a href="en/JS_LookupPropertyWithFlags">JS_LookupPropertyWithFlags</a>
</li><li> <a href="en/JS_LookupUCProperty">JS_LookupUCProperty</a>
</li><li> <a href="en/JS_NewPropertyIterator">JS_NewPropertyIterator</a>
</li><li> <a href="en/JS_NextProperty">JS_NextProperty</a>
</li><li> <a href="en/JS_SetProperty">JS_SetProperty</a>
</li><li> <a href="en/JS_SetPropertyAttributes">JS_SetPropertyAttributes</a>
</li><li> <a href="en/JS_SetUCProperty">JS_SetUCProperty</a>
</li><li> <a href="en/JS_SetUCPropertyAttributes">JS_SetUCPropertyAttributes</a>
</li><li> <a href="en/JS_AliasProperty">JS_AliasProperty</a> {{template.Deprecated_inline()}}
</li></ul>
<h4 name="Arrays"> Arrays </h4>
<ul><li> <a href="en/JS_NewArrayObject">JS_NewArrayObject</a>
</li><li> <a href="en/JS_IsArrayObject">JS_IsArrayObject</a>
</li></ul>
<ul><li> <a href="en/JS_HasArrayLength">JS_HasArrayLength</a>
</li><li> <a href="en/JS_GetArrayLength">JS_GetArrayLength</a>
</li><li> <a href="en/JS_SetArrayLength">JS_SetArrayLength</a>
</li></ul>
<ul><li> <a href="en/JS_AliasElement">JS_AliasElement</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_DefineElement">JS_DefineElement</a>
</li><li> <a href="en/JS_DeleteElement">JS_DeleteElement</a>
</li><li> <a href="en/JS_DeleteElement2">JS_DeleteElement2</a>
</li><li> <a href="en/JS_GetElement">JS_GetElement</a>
</li><li> <a href="en/JS_LookupElement">JS_LookupElement</a>
</li><li> <a href="en/JS_SetElement">JS_SetElement</a>
</li></ul>
<h4 name="Error_handling"> Error handling </h4>
<ul><li> type <a href="en/JSErrorReport">JSErrorReport</a>
</li><li> <a href="en/JS_ReportError">JS_ReportError</a>
</li><li> <a href="en/JS_ReportErrorNumber">JS_ReportErrorNumber</a>
</li><li> <a href="en/JS_ReportWarning">JS_ReportWarning</a>
</li><li> <a href="en/JS_ReportErrorFlagsAndNumber">JS_ReportErrorFlagsAndNumber</a>
</li><li> <a href="en/JS_ReportOutOfMemory">JS_ReportOutOfMemory</a>
</li><li> <a href="en/JS_ReportPendingException">JS_ReportPendingException</a>
</li><li> <a href="en/JS_ErrorFromException">JS_ErrorFromException</a>
</li><li> <a href="en/JS_SetErrorReporter">JS_SetErrorReporter</a>
</li></ul>
<p>The following functions allow C/C++ functions to throw and catch JavaScript exceptions:
</p>
<ul><li> <a href="en/JS_IsExceptionPending">JS_IsExceptionPending</a>
</li><li> <a href="en/JS_GetPendingException">JS_GetPendingException</a>
</li><li> <a href="en/JS_SetPendingException">JS_SetPendingException</a>
</li><li> <a href="en/JS_ClearPendingException">JS_ClearPendingException</a>
</li></ul>
<ul><li> <a href="en/JS_SaveExceptionState">JS_SaveExceptionState</a>
</li><li> <a href="en/JS_RestoreExceptionState">JS_RestoreExceptionState</a>
</li><li> <a href="en/JS_DropExceptionState">JS_DropExceptionState</a>
</li></ul>
<h4 name="Threading"> Threading </h4>
<p>The following functions support the SpiderMonkey threading model.  They are only available in <code><a href="en/JS_THREADSAFE">JS_THREADSAFE</a></code> builds.
</p>
<ul><li> <a href="en/JS_BeginRequest">JS_BeginRequest</a>
</li><li> <a href="en/JS_EndRequest">JS_EndRequest</a>
</li><li> <a href="en/JS_YieldRequest">JS_YieldRequest</a>
</li><li> <a href="en/JS_SuspendRequest">JS_SuspendRequest</a>
</li><li> <a href="en/JS_ResumeRequest">JS_ResumeRequest</a>
</li><li> <a href="en/JS_GetContextThread">JS_GetContextThread</a>
</li><li> <a href="en/JS_SetContextThread">JS_SetContextThread</a>
</li><li> <a href="en/JS_ClearContextThread">JS_ClearContextThread</a>
</li></ul>
<h3 name="Macros"> Macros </h3>
<ul><li> <a href="en/BOOLEAN_TO_JSVAL">BOOLEAN_TO_JSVAL</a>
</li><li> <a href="en/DOUBLE_TO_JSVAL">DOUBLE_TO_JSVAL</a>
</li><li> <a href="en/INT_FITS_IN_JSVAL">INT_FITS_IN_JSVAL</a>
</li><li> <a href="en/INT_TO_JSVAL">INT_TO_JSVAL</a>
</li><li> <a href="en/JS_DEFAULT_XML_NAMESPACE_ID">JS_DEFAULT_XML_NAMESPACE_ID</a>
</li><li> <a href="en/JS_GET_CLASS">JS_GET_CLASS</a>
</li><li> <a href="en/JS_MAP_GCROOT_NEXT">JS_MAP_GCROOT_NEXT</a>
</li><li> <a href="en/JS_MAP_GCROOT_REMOVE">JS_MAP_GCROOT_REMOVE</a>
</li><li> <a href="en/JS_MAP_GCROOT_STOP">JS_MAP_GCROOT_STOP</a>
</li><li> <a href="en/JSCLASS_CONSTUCT_PROTOTYPE">JSCLASS_CONSTUCT_PROTOTYPE</a>
</li><li> <a href="en/JSCLASS_HAS_PRIVATE">JSCLASS_HAS_PRIVATE</a>
</li><li> <a href="en/JSCLASS_HAS_RESERVED_SLOTS">JSCLASS_HAS_RESERVED_SLOTS</a>
</li><li> <a href="en/JSCLASS_IS_EXTENDED">JSCLASS_IS_EXTENDED</a>
</li><li> <a href="en/JSCLASS_NEW_ENUMERATE">JSCLASS_NEW_ENUMERATE</a>
</li><li> <a href="en/JSCLASS_NEW_RESOLVE">JSCLASS_NEW_RESOLVE</a>
</li><li> <a href="en/JSCLASS_RESERVED_SLOTS">JSCLASS_RESERVED_SLOTS</a>
</li><li> <a href="en/JSCLASS_SHARE_ALL_PROPERTIES">JSCLASS_SHARE_ALL_PROPERTIES</a>
</li><li> <a href="en/JSFUN_BOUND_METHOD">JSFUN_BOUND_METHOD</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JSFUN_GETTER">JSFUN_GETTER</a>
</li><li> <a href="en/JSFUN_GLOBAL_PARENT">JSFUN_GLOBAL_PARENT</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JSFUN_HEAVYWEIGHT">JSFUN_HEAVYWEIGHT</a>
</li><li> <a href="en/JSFUN_LAMBDA">JSFUN_LAMBDA</a>
</li><li> <a href="en/JSFUN_SETTER">JSFUN_SETTER</a>
</li><li> <a href="en/JSGC_MAX_BYTES">JSGC_MAX_BYTES</a>
</li><li> <a href="en/JSGC_MAX_MALLOC_BYTES">JSGC_MAX_MALLOC_BYTES</a>
</li><li> <a href="en/JSOPTION_ATLINE">JSOPTION_ATLINE</a>
</li><li> <a href="en/JSOPTION_COMPILE_N_GO">JSOPTION_COMPILE_N_GO</a>
</li><li> <a href="en/JSOPTION_DONT_REPORT_UNCAUGHT">JSOPTION_DONT_REPORT_UNCAUGHT</a>
</li><li> <a href="en/JSOPTION_NATIVE_BRANCH_CALLBACK">JSOPTION_NATIVE_BRANCH_CALLBACK</a>
</li><li> <a href="en/JSOPTION_RELIMIT">JSOPTION_RELIMIT</a>
</li><li> <a href="en/JSOPTION_STRICT">JSOPTION_STRICT</a>
</li><li> <a href="en/JSOPTION_VAROBJFIX">JSOPTION_VAROBJFIX</a>
</li><li> <a href="en/JSOPTION_WERROR">JSOPTION_WERROR</a>
</li><li> <a href="en/JSOPTION_XML">JSOPTION_XML</a>
</li><li> <a href="en/JSPRINCIPALS_DROP">JSPRINCIPALS_DROP</a>
</li><li> <a href="en/JSPRINCIPALS_HOLD">JSPRINCIPALS_HOLD</a>
</li><li> <a href="en/JSPROP_ENUMERATE">JSPROP_ENUMERATE</a>
</li><li> <a href="en/JSPROP_EXPORTED">JSPROP_EXPORTED</a>
</li><li> <a href="en/JSPROP_GETTER">JSPROP_GETTER</a>
</li><li> <a href="en/JSPROP_INDEX">JSPROP_INDEX</a>
</li><li> <a href="en/JSPROP_PERMANENT">JSPROP_PERMANENT</a>
</li><li> <a href="en/JSPROP_READONLY">JSPROP_READONLY</a>
</li><li> <a href="en/JSPROP_SETTER">JSPROP_SETTER</a>
</li><li> <a href="en/JSPROP_SHARED">JSPROP_SHARED</a>
</li><li> <a href="en/JSREG_GLOB">JSREG_GLOB</a>
</li><li> <a href="en/JSREG_FOLD">JSREG_FOLD</a>
</li><li> <a href="en/JSREG_MULTILINE">JSREG_MULTILINE</a>
</li><li> <a href="en/JSREPORT_ERROR">JSREPORT_ERROR</a>
</li><li> <a href="en/JSREPORT_EXCEPTION">JSREPORT_EXCEPTION</a>
</li><li> <a href="en/JSREPORT_STRICT">JSREPORT_STRICT</a>
</li><li> <a href="en/JSREPORT_WARNING">JSREPORT_WARNING</a>
</li><li> <a href="en/JSREPORT_IS_EXCEPTION">JSREPORT_IS_EXCEPTION</a>
</li><li> <a href="en/JSREPORT_IS_STRICT">JSREPORT_IS_STRICT</a>
</li><li> <a href="en/JSREPORT_IS_WARNING">JSREPORT_IS_WARNING</a>
</li><li> <a href="en/JSRESOLVE_ASSIGNING">JSRESOLVE_ASSIGNING</a>
</li><li> <a href="en/JSRESOLVE_CLASSNAME">JSRESOLVE_CLASSNAME</a>
</li><li> <a href="en/JSRESOLVE_DECLARING">JSRESOLVE_DECLARING</a>
</li><li> <a href="en/JSRESOLVE_DETECTING">JSRESOLVE_DETECTING</a>
</li><li> <a href="en/JSRESOLVE_QUALIFIED">JSRESOLVE_QUALIFIED</a>
</li><li> <a href="en/JSVAL_FALSE">JSVAL_FALSE</a>
</li><li> <a href="en/JSVAL_IS_BOOLEAN">JSVAL_IS_BOOLEAN</a>
</li><li> <a href="en/JSVAL_IS_DOUBLE">JSVAL_IS_DOUBLE</a>
</li><li> <a href="en/JSVAL_IS_GCTHING">JSVAL_IS_GCTHING</a>
</li><li> <a href="en/JSVAL_IS_INT">JSVAL_IS_INT</a>
</li><li> <a href="en/JSVAL_IS_NULL">JSVAL_IS_NULL</a>
</li><li> <a href="en/JSVAL_IS_NUMBER">JSVAL_IS_NUMBER</a>
</li><li> <a href="en/JSVAL_IS_OBJECT">JSVAL_IS_OBJECT</a>
</li><li> <a href="en/JSVAL_IS_PRIMITIVE">JSVAL_IS_PRIMITIVE</a>
</li><li> <a href="en/JSVAL_IS_STRING">JSVAL_IS_STRING</a>
</li><li> <a href="en/JSVAL_IS_VOID">JSVAL_IS_VOID</a>
</li><li> <a href="en/JSVAL_LOCK">JSVAL_LOCK</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JSVAL_NULL">JSVAL_NULL</a>
</li><li> <a href="en/JSVAL_ONE">JSVAL_ONE</a>
</li><li> <a href="en/JSVAL_TO_BOOLEAN">JSVAL_TO_BOOLEAN</a>
</li><li> <a href="en/JSVAL_TO_DOUBLE">JSVAL_TO_DOUBLE</a>
</li><li> <a href="en/JSVAL_TO_GCTHING">JSVAL_TO_GCTHING</a>
</li><li> <a href="en/JSVAL_TO_INT">JSVAL_TO_INT</a>
</li><li> <a href="en/JSVAL_TO_OBJECT">JSVAL_TO_OBJECT</a>
</li><li> <a href="en/JSVAL_TO_PRIVATE">JSVAL_TO_PRIVATE</a>
</li><li> <a href="en/JSVAL_TO_STRING">JSVAL_TO_STRING</a>
</li><li> <a href="en/JSVAL_TRUE">JSVAL_TRUE</a>
</li><li> <a href="en/JSVAL_UNLOCK">JSVAL_UNLOCK</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JSVAL_VOID">JSVAL_VOID</a>
</li><li> <a href="en/JSVAL_ZERO">JSVAL_ZERO</a>
</li><li> <a href="en/OBJECT_TO_JSVAL">OBJECT_TO_JSVAL</a>
</li><li> <a href="en/PRIVATE_TO_JSVAL">PRIVATE_TO_JSVAL</a>
</li><li> <a href="en/STRING_TO_JSVAL">STRING_TO_JSVAL</a>
</li></ul>
<h3 name="Deprecated"> Deprecated </h3>
<ul><li> <a href="en/JSFUN_BOUND_METHOD">JSFUN_BOUND_METHOD</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JSFUN_GLOBAL_PARENT">JSFUN_GLOBAL_PARENT</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JSVAL_LOCK">JSVAL_LOCK</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JSVAL_UNLOCK">JSVAL_UNLOCK</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_AliasElement">JS_AliasElement</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_AliasProperty">JS_AliasProperty</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_Finish">JS_Finish</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_GetFunctionName">JS_GetFunctionName</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_Init">JS_Init</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_Lock">JS_Lock</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_LockGCThing">JS_LockGCThing</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_Unlock">JS_Unlock</a> {{template.Deprecated_inline()}}
</li><li> <a href="en/JS_UnlockGCThing">JS_UnlockGCThing</a> {{template.Deprecated_inline()}}
</li></ul>
<h3 name="Preprocessor_conditionals"> Preprocessor conditionals </h3>
<ul><li> <a href="en/BUILD_OPT">BUILD_OPT</a>
</li><li> <a href="en/GC_MARK_DEBUG">GC_MARK_DEBUG</a>
</li><li> <a href="en/JS_ARENAMETER">JS_ARENAMETER</a>
</li><li> <a href="en/JS_GCMETER">JS_GCMETER</a>
</li><li> <a href="en/JS_HASHMETER">JS_HASHMETER</a>
</li><li> <a href="en/JS_THREADSAFE">JS_THREADSAFE</a>
</li></ul>
{{ wiki.languages( { "ja": "ja/JSAPI_Reference", "pl": "pl/Dokumentacja_JSAPI" } ) }}
Revert to this revision