JSAPI reference 编辑
The JSAPI is the C++ API for the SpiderMonkey JavaScript engine. To learn how to use the JSAPI, see the JSAPI User Guide and the JSAPI Cookbook.
Note: The FOSS wiki page contains a few links to other libraries and programs that can make life easier when using SpiderMonkey and the JSAPI. A note on versioning: Up until the release of Firefox 4, SpiderMonkey, and thus the JSAPI, was versioned in an ad-hoc way, with releases happening at times that roughly, but not really, corresponded to Firefox releases. In the fall of 2012, the SpiderMonkey team decided to align releases with those of Firefox. The reference applies this versioning scheme retroactively starting with Firefox 5. Firefox 4 is the last release that has a corresponding SpiderMonkey release with the old scheme, where the JSAPI has the version 1.8.5.Runtimes and contexts
JS_Init
Added in SpiderMonkey 31JS_ShutDown
- struct
JSRuntime
JS_NewRuntime
Obsolete since JSAPI 52JS_DestroyRuntime
JS_GetRuntimePrivate
JS_SetRuntimePrivate
JS_SetNativeStackQuota
Added in SpiderMonkey 17JS_ContextIterator
Obsolete since JSAPI 52
JS_Finish
Obsolete since JSAPI 19
- struct
JSContext
JS_NewContext
JS_DestroyContext
JS_DestroyContextNoGC
JS_SetContextCallback
- enum
JSContextOp
- enum
JS_GetRuntime
JS_GetParentRuntime
Added in SpiderMonkey 31JS_GetObjectRuntime
Added in SpiderMonkey 17
JS_GetContextPrivate
JS_SetContextPrivate
JS_GetSecondContextPrivate
Added in SpiderMonkey 17JS_SetSecondContextPrivate
Added in SpiderMonkey 17
JS_SetInterruptCallback
Added in SpiderMonkey 31JS_GetInterruptCallback
Added in SpiderMonkey 31JS_RequestInterruptCallback
Added in SpiderMonkey 31JS_CheckForInterrupt
Added in JSAPI 45
JS_DestroyContextMaybeGC
Obsolete since JSAPI 14JS_SetBranchCallback
Obsolete since JavaScript 1.9.1JS_SetOperationCallback
Obsolete since JSAPI 30JS_GetOperationCallback
Obsolete since JSAPI 30JS_TriggerOperationCallback
Obsolete since JSAPI 30JS_ClearOperationCallback
Obsolete since JavaScript 1.9.1JS_GetOperationLimit
Obsolete since JavaScript 1.9.1JS_SetOperationLimit
Obsolete since JavaScript 1.9.1JS_MAX_OPERATION_LIMIT
Obsolete since JavaScript 1.9.1JS_OPERATION_WEIGHT_BASE
Obsolete since JavaScript 1.9.1JS_SetThreadStackLimit
Obsolete since JSAPI 13JS_SetScriptStackQuota
Obsolete since JavaScript 1.8.6
JS_SetOptions
Obsolete since JSAPI 27JS_GetOptions
Obsolete since JSAPI 27JS_ToggleOptions
Obsolete since JSAPI 27
- enum
JSVersion
JS_GetImplementationVersion
JS_GetVersion
JS_SetVersionForCompartment
Added in SpiderMonkey 31JS_StringToVersion
JS_VersionToString
JS_SetVersion
Obsolete since JSAPI 25
JS::CurrentGlobalOrNull
Added in SpiderMonkey 31
JS_GetGlobalForScopeChain
Obsolete since JSAPI 25JS_GetGlobalObject
Obsolete since JSAPI 24JS_SetGlobalObject
Obsolete since JSAPI 25
JS_EnumerateResolvedStandardClasses
Obsolete since JSAPI 24
JS_IsAssigning
Obsolete since JavaScript 1.8.5JS_IsConstructing
Obsolete since JSAPI 26JS_IsConstructing_PossiblyWithGivenThisObject
Obsolete since JSAPI 17JS_GetScopeChain
Obsolete since JavaScript 1.8.7
Compartments:
- class
JSAutoCompartment
Added in SpiderMonkey 24 JS_NewGlobalObject
Added in SpiderMonkey 17JS_EnterCompartment
Added in SpiderMonkey 24JS_LeaveCompartment
Added in SpiderMonkey 24JS_GetCompartmentPrivate
Added in SpiderMonkey 1.8.5JS_SetCompartmentPrivate
Added in SpiderMonkey 1.8.5JS_GetGlobalForCompartmentOrNull
Added in SpiderMonkey 17JS_IterateCompartments
Added in SpiderMonkey 17JS_SetDestroyCompartmentCallback
Added in SpiderMonkey 17JS_SetCompartmentNameCallback
Added in SpiderMonkey 17
JS_NewCompartmentAndGlobalObject
Added in SpiderMonkey 1.8.1 Obsolete since JSAPI 16JS_EnterCrossCompartmentCall
Added in SpiderMonkey 1.8.1 Obsolete since JSAPI 18JS_LeaveCrossCompartmentCall
Added in SpiderMonkey 1.8.1 Obsolete since JSAPI 18
Locale callbacks:
Locale callback types:
Scripts
Just running some JavaScript code is straightforward:
- class
JS::CompileOptions
Added in SpiderMonkey 17 - class
JS::OwningCompileOptions
Added in SpiderMonkey 31 - class
JS::ReadonlyCompileOptions
Added in SpiderMonkey 31 - class
JS::SourceBufferHolder
Added in SpiderMonkey 31 JS::Evaluate
Added in SpiderMonkey 17
JS_EvaluateScript
Obsolete since JSAPI 36JS_EvaluateUCScript
Obsolete since JSAPI 36JS_EvaluateScriptForPrincipals
Obsolete since JSAPI 30JS_EvaluateUCScriptForPrincipals
Obsolete since JSAPI 30JS_EvaluateScriptForPrincipalsVersion
Obsolete since JSAPI 30JS_EvaluateUCScriptForPrincipalsVersion
Obsolete since JSAPI 30
You can instead compile JavaScript code into a JSScript
which you can then execute multiple times.
- class
JSScript
JS::Compile
Added in SpiderMonkey 17JS::CompileOffThread
Added in SpiderMonkey 31JS::CanCompileOffThread
Added in SpiderMonkey 31JS::FinishOffThreadScript
Added in SpiderMonkey 31JS_CompileScript
JS_CompileUCScript
JS_BufferIsCompilableUnit
JS_ExecuteScript
JS::CloneAndExecuteScript
Added in SpiderMonkey 31JS_DecompileScript
JS_ExecuteScriptVersion
Obsolete since JSAPI 36JS_CompileUTF8File
Added in SpiderMonkey 11 Obsolete since JSAPI 19JS_CompileUTF8FileHandle
Added in SpiderMonkey 11 Obsolete since JSAPI 19JS_CompileUTF8FileHandleForPrincipals
Added in SpiderMonkey 11 Obsolete since JSAPI 19JS_CompileFile
Obsolete since JSAPI 11JS_CompileFileHandle
Obsolete since JSAPI 11JS_CompileFileHandleForPrincipals
Obsolete since JSAPI 11JS_CompileScriptForPrincipals
Obsolete since JSAPI 28JS_CompileUCScriptForPrincipals
Obsolete since JSAPI 28JS_CompileScriptForPrincipalsVersion
Obsolete since JSAPI 19JS_CompileUCScriptForPrincipalsVersion
Obsolete since JSAPI 19JS_GetScriptObject
Obsolete since JSAPI 8JS_NewScriptObject
Obsolete since JSAPI 8JS_ExecuteScriptPart
Obsolete since JavaScript 1.9.3JS_DestroyScript
Obsolete since JSAPI 8
You can also compile JavaScript code into a function:
- struct
JSFunction
JS::CompileFunction
Added in SpiderMonkey 17JS_DecompileFunction
JS_DecompileFunctionBody
JS_CompileFunction
Obsolete since JSAPI 36JS_CompileFunctionForPrincipals
Obsolete since JSAPI 28JS_CompileUCFunction
Obsolete since JSAPI 36JS_CompileUCFunctionForPrincipals
Obsolete since JSAPI 28
Error handling
- struct
JSErrorFormatString
Added in SpiderMonkey 17 - class
JSErrorReport
- class
JS::AutoSaveExceptionState
Added in SpiderMonkey 31 - enum
JSExnType
Added in SpiderMonkey 17 JS_ReportError
JS_ReportWarning
JS_ReportErrorNumber
JS_ReportErrorNumberUC
JS_ReportErrorFlagsAndNumber
JS_ReportErrorFlagsAndNumberUC
JS_ReportErrorNumberUCArray
Added in SpiderMonkey 24JS_ReportOutOfMemory
JS_ReportAllocationOverflow
Added in SpiderMonkey 1.8JS_GetErrorReporter
JS_SetErrorReporter
Obsolete since JSAPI 52JS_ErrorFromException
JS_GetErrorPrototype
JSREPORT_IS_EXCEPTION
JSREPORT_IS_STRICT
JSREPORT_IS_WARNING
JSREPORT_IS_STRICT_MODE_ERROR
The following functions allow C/C++ functions to throw and catch JavaScript exceptions:
JS::CreateError
Added in SpiderMonkey 38JS_IsExceptionPending
JS_GetPendingException
JS_SetPendingException
JS_ClearPendingException
JS_ThrowStopIteration
Added in SpiderMonkey 1.8JS_IsStopIteration
Added in SpiderMonkey 31
These functions translate errors into exceptions and vice versa:
JS_ThrowReportedError
Obsolete since JSAPI 29
Values and types
JS::Value
constructors:
JS::NullValue
Added in SpiderMonkey 24JS::UndefinedValue
Added in SpiderMonkey 24JS::BooleanValue
Added in SpiderMonkey 24JS::TrueValue
Added in SpiderMonkey 24JS::FalseValue
Added in SpiderMonkey 24JS::NumberValue
Added in SpiderMonkey 24JS::Int32Value
Added in SpiderMonkey 24JS::DoubleValue
Added in SpiderMonkey 24JS::Float32Value
Added in SpiderMonkey 24JS::StringValue
Added in SpiderMonkey 24JS::ObjectValue
Added in SpiderMonkey 24JS::ObjectOrNullValue
Added in SpiderMonkey 24JS::SymbolValue
Added in SpiderMonkey 38
JS::Value
constants:
JS::NullHandleValue
Added in SpiderMonkey 24JS::UndefinedHandleValue
Added in SpiderMonkey 24JS::TrueHandleValue
Added in SpiderMonkey 38JS::FalseHandleValue
Added in SpiderMonkey 38
jsval
constants:
JSVAL_NULL
Obsolete since JSAPI 42JSVAL_VOID
Obsolete since JSAPI 42JSVAL_TRUE
Obsolete since JSAPI 42JSVAL_FALSE
Obsolete since JSAPI 42JSVAL_ZERO
Obsolete since JSAPI 42JSVAL_ONE
Obsolete since JSAPI 42
Function and macros for checking the type of a jsval
:
- enum
JSType
JS_TypeOfValue
All of the following are deprecated. See JS::Value
for their modern replacements.
JSVAL_IS_NULL
Obsolete since JSAPI 32JSVAL_IS_VOID
Obsolete since JSAPI 32JSVAL_IS_BOOLEAN
Obsolete since JSAPI 32JSVAL_IS_NUMBER
Obsolete since JSAPI 32JSVAL_IS_INT
Obsolete since JSAPI 32JSVAL_IS_DOUBLE
Obsolete since JSAPI 32JSVAL_IS_STRING
Obsolete since JSAPI 32JSVAL_IS_OBJECT
Obsolete since JSAPI 15JSVAL_IS_PRIMITIVE
Obsolete since JSAPI 32JSVAL_IS_GCTHING
Obsolete since JSAPI 32
High-level type-conversion routines for packing and unpacking function arguments.
JS_ConvertArguments
Obsolete since JSAPI 38JS_ConvertArgumentsVA
Obsolete since JSAPI 38JS_PushArguments
Obsolete since JavaScript 1.8.5JS_PushArgumentsVA
Obsolete since JavaScript 1.8.5JS_PopArguments
Obsolete since JavaScript 1.8.5JS_AddArgumentFormatter
Obsolete since JSAPI 18JS_RemoveArgumentFormatter
Obsolete since JSAPI 18
The following functions convert JS values to various types. They can be safely applied to jsval
s of any type. They may return new objects. For example, JS_ValueToObject(cx, s)
where s
is a string creates a new String
wrapper object. These functions may call JavaScript methods. For example, JS_ValueToString(cx, obj)
may call obj.toString()
.
JS::ToBoolean
Added in SpiderMonkey 17JS::ToUint16
Added in SpiderMonkey 17JS::ToInt32
Added in SpiderMonkey 17JS::ToUint32
Added in SpiderMonkey 17JS::ToInt64
Added in SpiderMonkey 17JS::ToUint64
Added in SpiderMonkey 17JS::ToNumber
Added in SpiderMonkey 17JS::ToString
Added in SpiderMonkey 31JS::OrdinaryToPrimitive
Added in SpiderMonkey 38JS_ValueToConstructor
JS_ValueToFunction
JS_ValueToObject
JS_ValueToSource
JS_ConvertValue
JS_ValueToBoolean
Obsolete since JSAPI 28JS_ValueToECMAInt32
Obsolete since JSAPI 26JS_ValueToECMAUint32
Obsolete since JSAPI 28JS_ValueToInt32
Obsolete since JSAPI 28JS_ValueToNumber
Obsolete since JSAPI 27JS_ValueToString
Obsolete since JSAPI 28JS_ValueToUint16
Obsolete since JSAPI 28
Fast, unchecked type-casting macros. These macros must not be applied to values that are not known to be the right type. Like C casts, they may cause crashes if applied to incorrect values. They never create new objects or call into JavaScript code.
BOOLEAN_TO_JSVAL
Obsolete since JSAPI 42INT_TO_JSVAL
Obsolete since JSAPI 42DOUBLE_TO_JSVAL
Obsolete since JSAPI 42OBJECT_TO_JSVAL
Obsolete since JSAPI 42STRING_TO_JSVAL
Obsolete since JSAPI 42PRIVATE_TO_JSVAL
Obsolete since JSAPI 42
INT_FITS_IN_JSVAL
Obsolete since JavaScript 1.8.5JSVAL_TO_BOOLEAN
Obsolete since JSAPI 32JSVAL_TO_INT
Obsolete since JSAPI 32JSVAL_TO_DOUBLE
Obsolete since JSAPI 32JSVAL_TO_OBJECT
Obsolete since JSAPI 32JSVAL_TO_STRING
Obsolete since JSAPI 32JSVAL_TO_GCTHING
Obsolete since JSAPI 32JSVAL_TO_PRIVATE
Obsolete since JSAPI 32
A function that behaves like typeof
:
JS_GetTypeName
Obsolete since JSAPI 34
And functions that behave like the equality operators:
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
. These functions also allow SpiderMonkey to account the number of bytes allocated:
JS_malloc
JS_free
JS_realloc
JS_strdup
- struct
JSFreeOp
Added in SpiderMonkey 17 JS_freeop
Added in SpiderMonkey 17JS_GetDefaultFreeOp
Added in SpiderMonkey 17
JavaScript objects, strings, and floating-point numbers are garbage collected. These functions provide access to the garbage collector:
JS_GC
JS_MaybeGC
JS_GetGCParameter
JS_SetGCParameter
JS_GetGCParameterForThread
Added in SpiderMonkey 17JS_SetGCParameterForThread
Added in SpiderMonkey 17JS_SetGCParametersBasedOnAvailableMemory
Added in SpiderMonkey 31- enum
JSGCParamKey
- enum
JS_SetGCCallback
- enum
JSGCStatus
- enum
JS_AddFinalizeCallback
Added in SpiderMonkey 38- enum
JSFinalizeStatus
Added in SpiderMonkey 17
- enum
JS_RemoveFinalizeCallback
Added in SpiderMonkey 38JS_SetGCZeal
Added in SpiderMonkey 1.8JS_ScheduleGC
Added in SpiderMonkey 17JS_DumpHeap
Added in SpiderMonkey 1.8
JS_SetGCCallbackRT
Obsolete since JSAPI 13JS_SetFinalizeCallback
Added in SpiderMonkey 17 Obsolete since JSAPI 32JS_MarkGCThing
Obsolete since JSAPI 5JS_IsAboutToBeFinalized
Obsolete since JSAPI 35JS_ClearNewbornRoots
Obsolete since JSAPI 5
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.
- class
JS::Rooted<T>
Added in SpiderMonkey 17- class
JS::RootedObject
Added in SpiderMonkey 17 - class
JS::RootedFunction
Added in SpiderMonkey 17 - class
JS::RootedScript
Added in SpiderMonkey 17 - class
JS::RootedString
Added in SpiderMonkey 17 - class
JS::RootedSymbol
Added in SpiderMonkey 38 - class
JS::RootedId
Added in SpiderMonkey 17 - class
JS::RootedValue
Added in SpiderMonkey 17
- class
- class
JS::Handle<T>
Added in SpiderMonkey 17- class
JS::HandleFunction
Added in SpiderMonkey 17 - class
JS::HandleId
Added in SpiderMonkey 17 - class
JS::HandleObject
Added in SpiderMonkey 17 - class
JS::HandleScript
Added in SpiderMonkey 17 - class
JS::HandleString
Added in SpiderMonkey 17 - class
JS::HandleSymbol
Added in SpiderMonkey 38 - class
JS::HandleValue
Added in SpiderMonkey 17
- class
- class
JS::MutableHandle<T>
Added in SpiderMonkey 17- class
JS::MutableHandleFunction
Added in SpiderMonkey 17 - class
JS::MutableHandleId
Added in SpiderMonkey 17 - class
JS::MutableHandleObject
Added in SpiderMonkey 17 - class
JS::MutableHandleScript
Added in SpiderMonkey 17 - class
JS::MutableHandleString
Added in SpiderMonkey 17 - class
JS::MutableHandleSymbol
Added in SpiderMonkey 38 - class
JS::MutableHandleValue
Added in SpiderMonkey 17
- class
- class
JS::PersistentRooted<T>
Added in SpiderMonkey 31- class
JS::PersistentRootedObject
Added in SpiderMonkey 31 - class
JS::PersistentRootedFunction
Added in SpiderMonkey 31 - class
JS::PersistentRootedScript
Added in SpiderMonkey 31 - class
JS::PersistentRootedString
Added in SpiderMonkey 31 - class
JS::PersistentRootedSymbol
Added in SpiderMonkey 38 - class
JS::PersistentRootedId
Added in SpiderMonkey 31 - class
JS::PersistentRootedValue
Added in SpiderMonkey 31
- class
- class
JS::AutoValueArray<N>
Added in SpiderMonkey 31 - class
JS::AutoVectorRooter<T>
Added in SpiderMonkey 17- class
JS::AutoValueVector
Added in SpiderMonkey 17 - class
JS::AutoIdVector
Added in SpiderMonkey 17 - class
JS::AutoObjectVector
Added in SpiderMonkey 24 - class
JS::AutoFunctionVector
Added in SpiderMonkey 31 - class
JS::AutoScriptVector
Added in SpiderMonkey 17
- class
- class
JS::HandleValueArray
Added in SpiderMonkey 31
JS::Add*Root
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::AddValueRoot
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::AddStringRoot
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::AddObjectRoot
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::AddNamedValueRoot
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::AddNamedValueRootRT
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::AddNamedScriptRoot
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::AddNamedStringRoot
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::AddNamedObjectRoot
Added in SpiderMonkey 31 Obsolete since JSAPI 38
JS::Remove*Root
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::RemoveValueRoot
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::RemoveStringRoot
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::RemoveObjectRoot
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::RemoveScriptRoot
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::RemoveValueRootRT
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::RemoveStringRootRT
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::RemoveObjectRootRT
Added in SpiderMonkey 31 Obsolete since JSAPI 38JS::RemoveScriptRootRT
Added in SpiderMonkey 31 Obsolete since JSAPI 38
JS_Add*Root
Obsolete since JSAPI 31JS_AddValueRoot
Obsolete since JSAPI 31JS_AddStringRoot
Obsolete since JSAPI 31JS_AddObjectRoot
Obsolete since JSAPI 31JS_AddGCThingRoot
Obsolete since JSAPI 31JS_AddNamedValueRoot
Obsolete since JSAPI 31JS_AddNamedStringRoot
Obsolete since JSAPI 31JS_AddNamedObjectRoot
Obsolete since JSAPI 31JS_AddNamedGCThingRoot
Obsolete since JSAPI 31
JS_Remove*Root
Obsolete since JSAPI 31JS_RemoveValueRoot
Obsolete since JSAPI 31JS_RemoveStringRoot
Obsolete since JSAPI 31JS_RemoveObjectRoot
Obsolete since JSAPI 31JS_RemoveGCThingRoot
Obsolete since JSAPI 31
JS_AddRoot
Obsolete since JavaScript 1.8.5JS_AddNamedRoot
Obsolete since JavaScript 1.8.5JS_AddNamedRootRT
Obsolete since JavaScript 1.8.5JS_RemoveRoot
Obsolete since JavaScript 1.8.5JS_RemoveRootRT
Obsolete since JavaScript 1.8.5JS_MapGCRoots
Obsolete since JSAPI 19JSGCMapRootFun
Obsolete since JSAPI 19JS_DumpNamedRoots
Obsolete since JSAPI 19
Local root scopes were another way of protecting objects from the garbage collector. They have been removed in JS 1.8.5, though
JS_EnterLocalRootScope
Obsolete since JavaScript 1.8.5JS_LeaveLocalRootScope
Obsolete since JavaScript 1.8.5JS_LeaveLocalRootScopeWithResult
Obsolete since JavaScript 1.8.5JS_ForgetLocalRoot
Obsolete since JavaScript 1.8.5
Added in SpiderMonkey 1.8 If an object contains references to other GC things that are not stored in SpiderMonkey data structures ("slots"), it must implement the
hook to enable the garbage collector to traverse those references. Otherwise the garbage collector will not find all reachable objects and may collect objects that are still reachable, leading to a crash. (In SpiderMonkey 1.7 and earlier, the JSTraceOp
JSMarkOp
hook was used instead. This has since been removed.)
The tracing APIs are used by the garbage collector and
hooks. JSAPI applications may also use them to examine the object graph. (For example, these APIs support very smooth integration between the JS garbage collector and other garbage collectors.)JSTraceOp
- struct
JSTracer
Added in SpiderMonkey 1.8 JS_TraceChildren
Added in SpiderMonkey 1.8JS_TraceRuntime
Added in SpiderMonkey 1.8
JSVAL_IS_TRACEABLE
Added in SpiderMonkey 1.8 Obsolete since JSAPI 31JSVAL_TO_TRACEABLE
Added in SpiderMonkey 1.8 Obsolete since JSAPI 31JSVAL_TRACE_KIND
Added in SpiderMonkey 1.8 Obsolete since JSAPI 31JS_TRACER_INIT
Added in SpiderMonkey 1.8 Obsolete since JSAPI 12JS_TracerInit
Added in SpiderMonkey 12 Obsolete since JSAPI 31JS_CallTracer
Added in SpiderMonkey 1.8 Obsolete since JSAPI 22JS_SET_TRACING_DETAILS
Added in SpiderMonkey 1.8 Obsolete since JSAPI 26JS_SET_TRACING_INDEX
Added in SpiderMonkey 1.8 Obsolete since JSAPI 26JS_SET_TRACING_NAME
Added in SpiderMonkey 1.8 Obsolete since JSAPI 26JS_CALL_TRACER
Added in SpiderMonkey 1.8 Obsolete since JSAPI 23JS_CALL_VALUE_TRACER
Added in SpiderMonkey 1.8 Obsolete since JSAPI 23JS_CALL_OBJECT_TRACER
Added in SpiderMonkey 1.8 Obsolete since JSAPI 23JS_CALL_STRING_TRACER
Added in SpiderMonkey 1.8 Obsolete since JSAPI 23JS_CALL_DOUBLE_TRACER
Added in SpiderMonkey 1.8 Obsolete since JavaScript 1.8.5JS_PrintTraceThingInfo
(DEBUG-only) Added in SpiderMonkey 1.8 Obsolete since JSAPI 16
Miscellaneous GC APIs:
JS_updateMallocCounter
Added in SpiderMonkey 17JS::SetLargeAllocationFailureCallback
Added in SpiderMonkey 31JS::SetOutOfMemoryCallback
Added in SpiderMonkey 31JS_EnumerateDiagnosticMemoryRegions
Added in SpiderMonkey 17
JSVAL_LOCK
Obsolete since JSAPI 18JSVAL_UNLOCK
Obsolete since JSAPI 18JS_LockGCThing
Obsolete since JSAPI 21JS_LockGCThingRT
Obsolete since JSAPI 22JS_UnlockGCThing
Obsolete since JSAPI 21JS_UnlockGCThingRT
Obsolete since JSAPI 22
Numbers
JS_NumberValue
Added in SpiderMonkey 17JS_DefineConstDoubles
- struct
JSConstDoubleSpec
- struct
JS_DefineConstIntegers
Added in SpiderMonkey 38- struct
JSConstIntegerSpec
Added in SpiderMonkey 38
- struct
JS_GetNaNValue
JS_GetNegativeInfinityValue
JS_GetPositiveInfinityValue
JS_DoubleIsInt32
Added in SpiderMonkey 17
JS_DoubleToInt32
Added in SpiderMonkey 17 Obsolete since JSAPI 38JS_DoubleToUint32
Added in SpiderMonkey 17 Obsolete since JSAPI 38JS_NewNumberValue
Obsolete since JSAPI 17JS_NewDoubleValue
Obsolete since JSAPI 17JS_NewDouble
Obsolete since JSAPI 17
Strings
- typedef
JSString
- class
JSAutoByteString
Added in SpiderMonkey 17 JS_NewStringCopyN
JS_NewStringCopyZ
JS_NewUCString
JS_NewUCStringCopyN
JS_NewUCStringCopyZ
JS_NewDependentString
JS_GetEmptyStringValue
JS_GetEmptyString
Added in SpiderMonkey 1.8.5JS_ConcatStrings
JS_CompareStrings
JS_StringEqualsAscii
Added in SpiderMonkey 1.8.5JS_FlatStringEqualsAscii
Added in SpiderMonkey 1.8.5
JS_StringHasLatin1Chars
Added in SpiderMonkey 38JS_GetStringCharAt
Added in SpiderMonkey 38JS_GetFlatStringCharAt
Added in SpiderMonkey 38JS_GetStringLength
JS_EncodeString
Added in SpiderMonkey 1.8JS_EncodeStringToUTF8
Added in SpiderMonkey 24JS_EncodeStringToBuffer
Added in SpiderMonkey 1.8.5JS_GetStringEncodingLength
Added in SpiderMonkey 1.8.5JS_GetLatin1FlatStringChars
Added in SpiderMonkey 38JS_GetTwoByteFlatStringChars
Added in SpiderMonkey 38JS_GetLatin1StringCharsAndLength
Added in SpiderMonkey 38JS_GetTwoByteStringCharsAndLength
Added in SpiderMonkey 38JS::GetDeflatedUTF8StringLength
Added in SpiderMonkey 38JS::DeflateStringToUTF8Buffer
Added in SpiderMonkey 38
JS_FileEscapedString
Added in SpiderMonkey 1.8.5JS_PutEscapedString
Added in SpiderMonkey 1.8.5JS_PutEscapedFlatString
Added in SpiderMonkey 1.8.5
JS_FORGET_STRING_FLATNESS
Added in SpiderMonkey 1.8.5JS_StringIsFlat
Added in SpiderMonkey 38JS_ASSERT_STRING_IS_FLAT
Added in SpiderMonkey 1.8.5JS_FlattenString
Added in SpiderMonkey 1.8.5
- typedef
jschar
Obsolete since JSAPI 35 JS_NewString
Obsolete since JSAPI 1.8.5JS_NewGrowableString
Obsolete since JSAPI 27JS_GetStringBytes
Obsolete since JSAPI 1.8.5JS_GetStringBytesZ
Obsolete since JSAPI 1.8.5JS_GetStringChars
Obsolete since JSAPI 1.8.5JS_GetStringCharsZ
Obsolete since JSAPI 33JS_GetStringCharsAndLength
Added in JSAPI 1.8.5 Obsolete since JSAPI 33JS_GetStringCharsZ
Added in SpiderMonkey 1.8.5 Obsolete since JSAPI 33JS_GetStringCharsZAndLength
Added in SpiderMonkey 1.8.5 Obsolete since JSAPI 33JS_GetFlatStringChars
Obsolete since JSAPI 33JS_MakeStringImmutable
Obsolete since JavaScript 1.8.5JS_EncodeCharacters
Obsolete since JSAPI 19JS_CStringsAreUTF8
Obsolete since JSAPI 19JS_SetCStringsAreUTF8
Obsolete since JSAPI 19
Interning strings tells the SpiderMonkey engine to reuse existing string objects when possible.
JS_InternString
JS_InternStringN
JS_InternUCString
JS_InternUCStringN
JS_InternJSString
Added in SpiderMonkey 1.8.5JS_StringHasBeenInterned
Added in SpiderMonkey 17
JS_GetLatin1InternedStringChars
Added in SpiderMonkey 38JS_GetTwoByteInternedStringChars
Added in SpiderMonkey 38
JS_GetInternedStringChars
Obsolete since JSAPI 33JS_GetInternedStringCharsAndLength
Obsolete since JSAPI 33
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.
- struct
JSStringFinalizer
Added in SpiderMonkey 17 JS_NewExternalString
JS_IsExternalString
Added in SpiderMonkey 17JS_GetTwoByteExternalStringChars
Added in SpiderMonkey 38JS_GetExternalStringFinalizer
Added in SpiderMonkey 17
JS_AddExternalStringFinalizer
Obsolete since JSAPI 13JS_RemoveExternalStringFinalizer
Obsolete since JSAPI 13JS_GetExternalStringGCType
Obsolete since JSAPI 13JS_NewExternalStringWithClosure
Added in SpiderMonkey 6 Obsolete since JSAPI 13JS_GetExternalStringClosure
Added in SpiderMonkey 6 Obsolete since JSAPI 13
Objects
- typedef
JSObject
JS_DefineObject
JS_NewObject
JS_NewPlainObject
Added in SpiderMonkey 38JS_NewObjectForConstructor
Added in SpiderMonkey 1.8.5JS_NewGlobalObject
Added in SpiderMonkey 1.8JS_NewObjectWithGivenProto
JS_New
Added in SpiderMonkey 1.8
JS_IsGlobalObject
Added in JSAPI 24
JS_ConstructObject
Obsolete since JSAPI 16JS_ConstructObjectWithArguments
Obsolete since JSAPI 16
JS_GetClass
JS_GetObjectPrototype
Added in JSAPI 17JS_GetFunctionPrototype
Added in SpiderMonkey 17JS_GetArrayPrototype
Added in SpiderMonkey 24JS_GetConstructor
JS_GetGlobalForObject
JS_GetInstancePrivate
JS_GetPrototype
JS_SetPrototype
JS_GetPrivate
JS_SetPrivate
JS_FreezeObject
Added in SpiderMonkey 1.8.5JS_DeepFreezeObject
Added in SpiderMonkey 1.8.5JS_IsExtensible
Added in SpiderMonkey 1.8.5JS_PreventExtensions
Added in SpiderMonkey 45JS_InstanceOf
JS_HasInstance
JS_IsNative
Added in SpiderMonkey 17JS::ToPrimitive
Added in SpiderMonkey 45JS::NewFunctionFromSpec
Added in SpiderMonkey 45
JS_DefaultValue
Obsolete since JSAPI 44JS_GET_CLASS
Obsolete since JSAPI 13JS_SealObject
Obsolete since JavaScript 1.8.5JS_GetParent
Obsolete since JSAPI 39JS_SetParent
Obsolete since JSAPI 39
Standard Objects
- enum
JSProtoKey
Added in SpiderMonkey 24 JS_GetClassObject
JS_GetClassPrototype
JS::ProtoKeyToId
Added in SpiderMonkey 38JS_IdToProtoKey
Added in SpiderMonkey 31JS::IdentifyStandardInstance
Added in SpiderMonkey 31JS::IdentifyStandardPrototype
Added in SpiderMonkey 31JS::IdentifyStandardInstanceOrPrototype
Added in SpiderMonkey 31JS::IdentifyStandardConstructor
Added in SpiderMonkey 38
Date
JS_NewDateObject
Added in SpiderMonkey 1.8.5JS_NewDateObjectMsec
Added in SpiderMonkey 1.8.5JS_ObjectIsDate
Added in SpiderMonkey 1.8.5JS_ClearDateCaches
Added in SpiderMonkey 17JS_Now
Intl API
JS_SetDefaultLocale
Added in SpiderMonkey 24JS_ResetDefaultLocale
Added in SpiderMonkey 24
Properties
These functions correspond directly to the ways scripts access object properties:
JS_GetProperty
JS_GetUCProperty
JS_GetPropertyById
Added in SpiderMonkey 1.8.1JS_SetProperty
JS_SetUCProperty
JS_SetPropertyById
Added in SpiderMonkey 1.8.1JS_HasProperty
JS_HasUCProperty
JS_HasPropertyById
Added in SpiderMonkey 1.8.1JS_HasOwnProperty
Added in JSAPI 45JS_HasOwnPropertyById
Added in JSAPI 45JS_DeleteProperty
JS_DeletePropertyById
Added in SpiderMonkey 1.8.1
JS_DeleteProperty2
Obsolete since JSAPI 39JS_DeleteUCProperty2
Obsolete since JSAPI 39JS_DeletePropertyById2
Added in SpiderMonkey 1.8.1 Obsolete since JSAPI 39
The following functions are lower-level, allowing the JSAPI application more access to details of how properties are implemented. "Define" is a lower-level version of "set" that provides access to extra settings and does not call setters. Similarly, "lookup" is a lower-level version of "get" that offers extra options and does not call getters.
- struct
JSPropertyDescriptor
Added in SpiderMonkey 1.8 Property attributes
JSPROP_ENUMERATE
JSPROP_READONLY
JSPROP_PERMANENT
JSPROP_PROPOP_ACCESSORS
Added in SpiderMonkey 38JSPROP_GETTER
JSPROP_SETTER
JSPROP_SHARED
JSPROP_INDEX
JSPROP_DEFINE_LATE
Added in SpiderMonkey 38JSFUN_STUB_GSOPS
Added in SpiderMonkey 17JSFUN_CONSTRUCTOR
Added in SpiderMonkey 17JSPROP_REDEFINE_NONCONFIGURABLE
Added in SpiderMonkey 38JSPROP_RESOLVING
Added in SpiderMonkey 45JSPROP_IGNORE_ENUMERATE
Added in SpiderMonkey 38JSPROP_IGNORE_READONLY
Added in SpiderMonkey 38JSPROP_IGNORE_PERMANENT
Added in SpiderMonkey 38JSPROP_IGNORE_VALUE
Added in SpiderMonkey 38
JS_AlreadyHasOwnElement
Added in SpiderMonkey 1.8JS_AlreadyHasOwnProperty
Added in SpiderMonkey 1.8JS_AlreadyHasOwnUCProperty
Added in SpiderMonkey 1.8JS_AlreadyHasOwnPropertyById
Added in SpiderMonkey 1.8.1JS_DefineProperty
JS_DefineUCProperty
JS_DefinePropertyById
Added in SpiderMonkey 1.8.1JS_DefineProperties
JS_Enumerate
JS_ForwardGetPropertyTo
Added in SpiderMonkey 17JS_ForwardGetElementTo
Added in SpiderMonkey 17JS_GetPropertyDescriptor
Added in SpiderMonkey 31JS_GetPropertyDescriptorById
Added in SpiderMonkey 1.8.1JS_GetOwnPropertyDescriptor
Added in SpiderMonkey 31JS_GetOwnPropertyDescriptorById
Added in SpiderMonkey 31JS_GetOwnUCPropertyDescriptor
Added in SpiderMonkey 45JS_SetAllNonReservedSlotsToUndefined
Added in SpiderMonkey 24
JS_AliasProperty
Obsolete since JSAPI 8JS_ClearScope
Obsolete since JSAPI 18JS_ClearNonGlobalObject
Added in SpiderMonkey 18 Obsolete since JSAPI 34JS_DefineOwnProperty
Added in SpiderMonkey 1.8.5 Obsolete since JSAPI 33JS_DefinePropertyWithTinyId
Obsolete since JSAPI 30JS_DefineUCPropertyWithTinyId
Obsolete since JSAPI 30JS_GetPropertyDefault
Obsolete since JSAPI 26JS_GetPropertyByIdDefault
Obsolete since JSAPI 26JS_GetPropertyAttributes
Obsolete since JSAPI 26JS_GetUCPropertyAttributes
Obsolete since JSAPI 26JS_GetPropertyAttrsGetterAndSetter
Obsolete since JSAPI 26JS_GetUCPropertyAttrsGetterAndSetter
Obsolete since JSAPI 26JS_GetPropertyAttrsGetterAndSetterById
Obsolete since JSAPI 26JS_LookupProperty
Obsolete since JSAPI 37JS_LookupUCProperty
Obsolete since JSAPI 37JS_LookupPropertyById
Obsolete since JSAPI 37JS_LookupElement
Obsolete since JSAPI 37JS_LookupPropertyWithFlags
Obsolete since JSAPI 31JS_LookupPropertyWithFlagsById
Obsolete since JSAPI 31JS_NewPropertyIterator
Obsolete since JSAPI 36JS_NextProperty
Obsolete since JSAPI 36JS_SetPropertyAttributes
Obsolete since JSAPI 26JS_SetUCPropertyAttributes
Obsolete since JSAPI 26
The following functions behave like JS_GetProperty
and JS_GetPropertyById
except when operating on E4X XML objects.
JS_GetMethod
Obsolete since JSAPI 23JS_GetMethodById
Obsolete since JSAPI 23
A SpiderMonkey extension allows a native function to return an lvalue—that is, a reference to a property of an object:
JS_SetCallReturnValue2
Obsolete since JavaScript 1.8.5
Id
A jsid
is an identifier for a property or method of an object.
- struct
jsid
JS_IdToValue
JS_IdToProtoKey
Added in SpiderMonkey 31JS_ValueToId
JS_StringToId
Added in SpiderMonkey 38JS_IndexToId
Added in SpiderMonkey 17JS_CharsToId
Added in SpiderMonkey 24JS::ProtoKeyToId
Added in SpiderMonkey 38JS_IsIdentifier
Added in SpiderMonkey 17
- struct
JSIdArray
- class
JS::AutoIdArray
Added in SpiderMonkey 17 JS_IdArrayLength
Added in SpiderMonkey 17JS_IdArrayGet
Added in SpiderMonkey 17JS_DestroyIdArray
JS_GetObjectId
Obsolete since JSAPI 31
jsid
constants:
JSID_VOID
JSID_VOIDHANDLE
Added in SpiderMonkey 31JSID_EMPTY
JSID_EMPTYHANDLE
Added in SpiderMonkey 31
Function for checking and converting the type of a jsid
:
JSID_IS_ZERO
JSID_IS_VOID
JSID_IS_EMPTY
JSID_IS_STRING
JSID_TO_STRING
INTERNED_STRING_TO_JSID
Added in SpiderMonkey 38JSID_TO_FLAT_STRING
Added in SpiderMonkey 17JSID_IS_INT
JSID_TO_INT
INT_FITS_IN_JSID
INT_TO_JSID
JSID_IS_SYMBOL
Added in SpiderMonkey 38JSID_TO_SYMBOL
Added in SpiderMonkey 38SYMBOL_TO_JSID
Added in SpiderMonkey 38JSID_IS_GCTHING
JSID_TO_GCTHING
JSID_IS_OBJECT
Obsolete since JSAPI 33JSID_IS_DEFAULT_XML_NAMESPACE
Obsolete since JSAPI 21
Classes
These API features are used to define custom classes—object types that are implemented in C/C++ code but accessible from JavaScript.
- struct
JSClass
- struct
JSFunctionSpec
- struct
JSPropertySpec
JS_InitClass
JS_LinkConstructorAndPrototype
Added in SpiderMonkey 17JS::PropertySpecNameIsSymbol
Added in SpiderMonkey 38JS::PropertySpecNameEqualsId
Added in SpiderMonkey 38JS::PropertySpecNameToPermanentId
Added in SpiderMonkey 38JS_GetReservedSlot
JS_SetReservedSlot
- struct
JSExtendedClass
Obsolete since JavaScript 1.8.5 - struct
JSObjectOps
Obsolete since JavaScript 1.8.5 - struct
JSXMLObjectOps
Obsolete since JavaScript 1.8.5 - struct
JSProperty
Obsolete since JSAPI 16
Adding native properties and methods to classes:
JSNative
- struct
JSFunctionSpec
JS_FS
Added in SpiderMonkey 1.8JS_FN
Added in SpiderMonkey 1.8JS_SYM_FN
Added in SpiderMonkey 38JS_FNINFO
Added in SpiderMonkey 17JS_SELF_HOSTED_FN
Added in SpiderMonkey 31JS_SELF_HOSTED_SYM_FN
Added in SpiderMonkey 38JS_SYM_FNSPEC
Added in SpiderMonkey 38JS_FNSPEC
Added in SpiderMonkey 31JS_FS_END
Added in SpiderMonkey 1.8- struct
JSPropertySpec
JS_PSG
Added in SpiderMonkey 17JS_PSGS
Added in SpiderMonkey 17JS_SELF_HOSTED_GET
Added in SpiderMonkey 31JS_SELF_HOSTED_GETSET
Added in SpiderMonkey 31JS_PS_END
Added in SpiderMonkey 17
JSFastNative
Added in SpiderMonkey 1.8 Obsolete since JavaScript 1.8.5
The behavior of a JSClass
can be customized using these flags:
JSClass.flags
JSCLASS_HAS_PRIVATE
JSCLASS_PRIVATE_IS_NSISUPPORTS
JSCLASS_IS_DOMJSCLASS
Added in SpiderMonkey 17JSCLASS_IMPLEMENTS_BARRIERS
Added in SpiderMonkey 17JSCLASS_EMULATES_UNDEFINED
Added in SpiderMonkey 24JSCLASS_HAS_RESERVED_SLOTS(n)
JSCLASS_GLOBAL_FLAGS
JSCLASS_NEW_ENUMERATE
Obsolete since JSAPI 37JSCLASS_NEW_RESOLVE
Obsolete since JSAPI 36JSCLASS_SHARE_ALL_PROPERTIES
Obsolete since JavaScript 1.8.5JSCLASS_NEW_RESOLVE_GETS_START
Obsolete since JSAPI 16JSCLASS_CONSTRUCT_PROTOTYPE
Obsolete since JSAPI 11JSCLASS_IS_EXTENDED
Obsolete since JSAPI 17JSCLASS_MARK_IS_TRACE
Obsolete since JSAPI 5
The behavior of a JSClass
and its instances can be customized in many ways using callback functions.
JSClass
method types:
JSPropertyOp
JSStrictPropertyOp
Added in SpiderMonkey 1.9.3JSDeletePropertyOp
Added in SpiderMonkey 24JSEnumerateOp
JSNewEnumerateOp
JSResolveOp
JSConvertOp
JSFinalizeOp
JSHasInstanceOp
JSTraceOp
JSCheckAccessOp
ObsoleteJSXDRObjectOp
Obsolete since JSAPI 13JSNewResolveOp
Obsolete since JSAPI 36JSMarkOp
Obsolete since JSAPI 5JSGetObjectOps
Obsolete since JavaScript 1.8.5JSReserveSlotsOp
Obsolete since JavaScript 1.8.5
These stub functions can be used when creating a custom JSClass
:
JS_ConvertStub
Obsolete since JSAPI 37JS_DeletePropertyStub
Obsolete since JSAPI 37JS_EnumerateStub
Obsolete since JSAPI 37JS_FinalizeStub
Obsolete since JSAPI 15JS_ResolveStub
Obsolete since JSAPI 37
JSExtendedClass
method types:
In JS 1.8.5, JSExtendedClass
has made private.
JSIteratorOp
Obsolete since JSAPI 26JSEqualityOp
Obsolete since JavaScript 1.8.5JSObjectOp
Obsolete since JavaScript 1.8.5
JSObjectOps
method types:
In JS 1.8.5, JSObjectOps
has been made private.
JSNewObjectMapOp
Obsolete since JavaScript 1.8.5JSObjectMapOp
Obsolete since JavaScript 1.8.5JSLookupPropOp
Obsolete since JavaScript 1.8.5JSDefinePropOp
Obsolete since JavaScript 1.8.5JSPropertyIdOp
Obsolete since JavaScript 1.8.5JSAttributesOp
Obsolete since JavaScript 1.8.5JSObjectOps.defaultValue
Obsolete since JavaScript 1.8.5JSCheckAccessIdOp
Obsolete since JavaScript 1.8.5JSObjectOp
Obsolete since JavaScript 1.8.5JSPropertyRefOp
Obsolete since JavaScript 1.8.5JSSetObjectSlotOp
Obsolete since JavaScript 1.8.5JSGetRequiredSlotOp
Obsolete since JavaScript 1.8.5JSSetRequiredSlotOp
Obsolete since JavaScript 1.8.5
JSXMLObjectOps
method types:
In JS 1.8.5, JSXMLObjectOps
has been made private.
JSGetMethodOp
Obsolete since JavaScript 1.8.5JSSetMethodOp
Obsolete since JavaScript 1.8.5JSEnumerateValuesOp
Obsolete since JavaScript 1.8.5JSConcatenateOp
Obsolete since JavaScript 1.8.5
Arrays
JS_HasArrayLength
Obsolete since JSAPI 8JS_AliasElement
Obsolete since JSAPI 8JS_LookupElement
Obsolete since JSAPI 37JS_DeleteElement2
Obsolete since JSAPI 39
Functions
Calling a function or a method of an object:
- class
JS::CallArgs
Added in SpiderMonkey 17 JS::CallArgsFromVp
Added in SpiderMonkey 17JS::Call
Added in SpiderMonkey 17JS::Construct
Added in SpiderMonkey 38JS_CallFunction
JS_CallFunctionName
JS_CallFunctionValue
JS::IsCallable
Added in SpiderMonkey 38JS::IsConstructor
Added in SpiderMonkey 38JS_IsNativeFunction
Added in SpiderMonkey 17JS_IsConstructor
Added in SpiderMonkey 24JS_BindCallable
Added in SpiderMonkey 17JS_IsBuiltinEvalFunction
Added in SpiderMonkey 17JS_IsBuiltinFunctionConstructor
Added in SpiderMonkey 17
Function accessors:
JS_ObjectIsFunction
JS_GetFunctionArity
JS_GetFunctionId
JS_GetFunctionDisplayId
Added in SpiderMonkey 17JS_GetFunctionScript
Added in SpiderMonkey 38JS_GetFunctionObject
JS_GetFunctionFlags
Obsolete since JSAPI 19JS_GetFunctionName
Obsolete since JavaScript 1.8.5
Creating functions:
JS::CloneFunctionObject
Added in SpiderMonkey 36JS_DefineFunction
JS_DefineUCFunction
JS_DefineFunctionById
Added in SpiderMonkey 17JS_DefineFunctions
- enum
PropertyDefinitionBehavior
Added in SpiderMonkey 38
- enum
JS_NewFunction
JS::GetSelfHostedFunction
Added in JSAPI 31JS::NewFunctionFromSpec
Added in JSAPI 45
JS_NewFunctionById
Added in SpiderMonkey 17 Obsolete since JSAPI 44JS_CloneFunctionObject
Obsolete since JSAPI 36
RegExps
JS_NewRegExpObject
JS_NewUCRegExpObject
JS_NewRegExpObjectNoStatics
JS_NewUCRegExpObjectNoStatics
JS_SetRegExpInput
JS_ClearRegExpStatics
JS_ObjectIsRegExp
Added in SpiderMonkey 17JS_GetRegExpFlags
Added in SpiderMonkey 17JS_GetRegExpSource
Added in SpiderMonkey 17JS_ExecuteRegExp
JS_ExecuteRegExpNoStatics
JS_ClearRegExpRoots
Obsolete since JavaScript 1.8.5
Serialization
- struct
JSStructuredCloneCallbacks
- JS_SetStructuredCloneCallbacks
- JS_ReadStructuredClone
- JS_WriteStructuredClone
- JS_StructuredClone
- JS_ReadUint32Pair
- JS_ReadBytes
- JS_WriteUint32Pair
- JS_WriteBytes
Security
- struct
JSPrincipals
JS_SetObjectPrincipalsFinder
Obsolete since JavaScript 1.8JS_SetPrincipalsTranscoder
Obsolete since JavaScript 1.8
- enum
JSAccessMode
Obsolete since JSAPI 29 JS_CheckAccess
Obsolete since JSAPI 29JSObjectOps.checkAccess
Obsolete since JavaScript 1.8JSClass.checkAccess
Obsolete since JSAPI 29JS_SetCheckObjectAccessCallback
Obsolete since JavaScript 1.8
Added in SpiderMonkey 1.8.1 Security callbacks are set per-runtime.
JSSecurityCallbacks
JS_GetSecurityCallbacks
Added in SpiderMonkey 13JS_SetSecurityCallbacks
Added in SpiderMonkey 13JS_SetContextSecurityCallbacks
Obsolete since JSAPI 13JS_GetRuntimeSecurityCallbacks
Obsolete since JSAPI 13JS_SetRuntimeSecurityCallbacks
Obsolete since JSAPI 13
Threading
The following functions support the SpiderMonkey threading model.
Note: JS_THREADSAFE is now permanently on and the JSRuntime is single-threaded. To execute more than one JS script at once, use multiple JSRuntimes.
JSAPI 1.7 and earlier They are only available in
builds.JS_THREADSAFE
Added in SpiderMonkey 1.8 These functions are always available, but in non-
builds, they do nothing.JS_THREADSAFE
JS_BeginRequest
JS_EndRequest
JS_YieldRequest
Obsolete since JSAPI 18JS_SuspendRequest
Obsolete since JSAPI 18JS_ResumeRequest
Obsolete since JSAPI 18JS_GetContextThread
Obsolete since JSAPI 8JS_SetContextThread
Obsolete since JSAPI 8JS_ClearContextThread
Obsolete since JSAPI 8
The following functions are always available, but in non-
builds, they do nothing:JS_THREADSAFE
JS_LockRuntime
Obsolete since JSAPI 12JS_UnlockRuntime
Obsolete since JSAPI 12JS_Lock
Obsolete since JSAPI 12JS_Unlock
Obsolete since JSAPI 12
Time
Callback Types
Native function types:
JSNative
JSFastNative
Obsolete since JavaScript 1.8.5
Other callback types:
JS::LargeAllocationFailureCallback
- used byJS::SetLargeAllocationFailureCallback
Added in SpiderMonkey 31JS::OffThreadCompileCallback
- used byJS::CompileOffThread
Added in SpiderMonkey 26JS::SetOutOfMemoryCallback
- used byJS::OutOfMemoryCallback
Added in SpiderMonkey 31JSCompartmentNameCallback
- used byJS_SetCompartmentNameCallback
Added in SpiderMonkey 17JSContextCallback
- used byJS_SetContextCallback
JSDestroyCompartmentCallback
- used byJS_SetDestroyCompartmentCallback
Added in SpiderMonkey 17JSEnumerateDiagnosticMemoryCallback
- used byJS_EnumerateDiagnosticMemoryRegions
Added in SpiderMonkey 17JSErrorCallback
- used byJS_ReportErrorNumber
and friendsJSErrorReporter
- used byJS_SetErrorReporter
JSGCCallback
- used byJS_SetGCCallback
JSFinalizeCallback
Added in SpiderMonkey 17
- used byJS_AddFinalizeCallback
Added in SpiderMonkey 38
andJS_SetFinalizeCallback
Added in SpiderMonkey 17 Obsolete since JSAPI 32JSIterateCompartmentCallback
- used byJS_IterateCompartments
Added in SpiderMonkey 17JSBranchCallback
- used byJS_SetBranchCallback
Obsolete since JavaScript 1.8.1JSArgumentFormatter
- used byJS_AddArgumentFormatter
Obsolete since JSAPI 18JSFunctionCallback
- used byJS_SetFunctionCallback
Obsolete since JSAPI 37JSGCRootMapFun
- used byJS_MapGCRoots
Obsolete since JSAPI 19JSObjectPrincipalsFinder
- used byJS_SetObjectPrincipalsFinder
Obsolete since JavaScript 1.8JSPrincipalsTranscoder
- used byJS_SetPrincipalsTranscoder
Obsolete since JavaScript 1.8JSStringFinalizeOp
- used byJS_AddExternalStringFinalizer
Obsolete since JSAPI 13JSTraceCallback
- used byJS_TRACER_INIT
Obsolete since JSAPI 12JSTraceDataOp
- used byJS_SetExtraGCRoots
Obsolete since JSAPI 25JSTraceNamePrinter
- used byJS_SET_TRACING_DETAILS
Obsolete since JSAPI 26
See also Classes, above.
Macros
JS_DEFAULT_XML_NAMESPACE_ID
Obsolete since JSAPI 21JSFUN_BOUND_METHOD
Obsolete since JavaScript 1.8.5JSFUN_GETTER
Obsolete since JavaScript 1.8.5JSFUN_SETTER
Obsolete since JavaScript 1.8.5JSFUN_GLOBAL_PARENT
Obsolete since JavaScript 1.8.5JSFUN_HEAVYWEIGHT
Obsolete since JSAPI 19JSFUN_LAMBDA
Obsolete since JSAPI 19
C++ features
- class
JSAutoRequest
- class
JSAutoLocalRootScope
Obsolete since JavaScript 1.8.5 - class JS::PerfMeasurement (in
jsperf.h
)
Tracing and debugging
JS_SetFunctionCallback
Added in SpiderMonkey 1.8.5 Obsolete since JSAPI 37JS_GetFunctionCallback
Added in SpiderMonkey 1.8.5 Obsolete since JSAPI 37
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论