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 *.

MethodDescription
const T &get() constReturns *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&lt;T&gt;. It is used in the same way as JS::Handle&lt;T&gt; and includes a |set(const T &v)| method to allow updating the value of the referenced JS::Rooted&lt;T&gt;. A JS::MutableHandle<T> can be created from a JS::Rooted&lt;T&gt; 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:93 次

字数:5275

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文