JS::MutableHandle 编辑
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 *ptr to v . |
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论