JS_ValueToId 编辑

Convert a JS::Value to type jsid.

Syntax

bool
JS_ValueToId(JSContext *cx, JS::HandleValue v, JS::MutableHandleId idp);

bool
JS_StringToId(JSContext *cx, JS::HandleString s, JS::MutableHandleId idp); // Added in SpiderMonkey 38

bool
JS_IndexToId(JSContext *cx, uint32_t index, JS::MutableHandleId idp); // Added in SpiderMonkey 17

bool
JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, JS::MutableHandleId idp); // Added in SpiderMonkey 24

void
JS::ProtoKeyToId(JSContext *cx, JSProtoKey key, JS::MutableHandleId idp); // Added in SpiderMonkey 38
NameTypeDescription
cxJSContext *A context. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
vJS::HandleValueThe JS value to convert.
sJS::HandleStringThe JS string to convert.
indexuint32_tAn unsigned integer index of array to convert.
charsJS::TwoByteCharsThe string to convert.
keyJSProtoKeyThe prototype key to convert.
idpJS::MutableHandleIdOut parameter. On success, *idp receives the converted jsid.

Description

JS_ValueToId converts a specified JS::Value, v, to a jsid. If v is an integer, *idp receives an integer jsid. Otherwise, if E4X support is enabled and v is an object, *idp receives an object jsid. Otherwise, *idp receives an interned string jsid based on the value of v. If v is not a string, it is converted to a string as if by calling JS_ValueToString.

JS_StringToId and JS_CharsToId convert a specified string to a jsid.

JS_IndexToId converts a specified integer index to an integer jsid.

JS::ProtoKeyToId converts a specified prototype key to a jsid.

On success, JS_ValueToId stores the converted value in *idp and returns true. Otherwise it returns false.

The inverse of JS_ValueToId is JS_IdToValue.

MXR ID Search for JS_ValueToId

See Also

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

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

发布评论

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

词条统计

浏览:94 次

字数:7057

最后编辑:7年前

编辑次数:0 次

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