This article covers features introduced in SpiderMonkey 17
Reference to a T that has been rooted elsewhere. The underlying storage can be changed. This is useful for outparams.
Syntax
bool
someFunction(JSContext *cx, JS::MutableHandle<T> outParam) {
...
}
Methods
Here, ptr represents the private member of JS::MutableHandle<T>, typed with T *.
| Method | Description | 
|---|---|
| const T &get() const | Returns *ptr. | 
| operator const T&() const | |
| T operator->() const | |
| T *address() | Returns ptr. | 
| void set(T v) | Sets the value of *ptrtov. | 
Description
JS::MutableHandle<T> is a non-const reference to JS::Rooted<T>. It is used in the same way as JS::Handle<T> and includes a |set(const T &v)| method to allow updating the value of the referenced JS::Rooted<T>. A JS::MutableHandle<T> can be created from a JS::Rooted<T> by using |JS::Rooted<T>::operator&()|.
If you want to add additional methods to JS::MutableHandle for a specific specialization, define a js::MutableHandleBase<T> specialization containing them.
There are typedefs available for the main types:
namespace JS {
typedef MutableHandle<JSFunction*> MutableHandleFunction;
typedef MutableHandle<jsid>        MutableHandleId;
typedef MutableHandle<JSObject*>   MutableHandleObject;
typedef MutableHandle<JSScript*>   MutableHandleScript;
typedef MutableHandle<JSString*>   MutableHandleString;
typedef MutableHandle<JS::Symbol*> MutableHandleSymbol;
typedef MutableHandle<Value>       MutableHandleValue;
}
See Also
- MXR ID Search for JS::MutableHandle
- MXR ID Search for JS::MutableHandleFunction
- MXR ID Search for JS::MutableHandleId
- MXR ID Search for JS::MutableHandleObject
- MXR ID Search for JS::MutableHandleScript
- MXR ID Search for JS::MutableHandleString
- MXR ID Search for JS::MutableHandleSymbol
- MXR ID Search for JS::MutableHandleValue
- JS::Rooted
- JS::Handle
- GC Rooting Guide
- bug 770759
- bug 761391 - added JS::MutableHandleScript
- bug 645416 - added JS::MutableHandleSymbol