JSFunctionSpec 编辑

Defines a single function for an object.

Syntax

struct JSFunctionSpec {
    const char      *name;
    JSNativeWrapper call;
    uint16_t        nargs;
    uint16_t        flags;
    const char      *selfHostedName;
};

typedef struct JSNativeWrapper {
    JSNative        op;
    const JSJitInfo *info;
} JSNativeWrapper;
NameTypeDescription
nameconst char *The function's name.
callJSNativeWrapperThe built-in JS call wrapped by this function. If the function does not wrap a native JS call, set this value to NULL.
nargsuint16_tThe value used for Function.length. This no longer guarantees anything about the vp array.
flagsuint16_tThe bitwise OR of any number of function flags.
selfHostedNameconst char *The function's name in Self-Hosted JavaScript code.

Description

JSFunctionSpec defines the attributes for a single JS function to associate with an object. An application typically has an array of JSFunctionSpec to define all the functions for an object and calls JS_DefineFunctions or JS_InitClass to create the functions and assign them to an object.

JSFunctionSpec can also be used to define an array element rather than a named property. Array elements are actually individual properties. To define an array element, cast the element's index value to const char*, initialize the name field with it, and specify the JSPROP_INDEX attribute in flags.

To define an array of JSPropertySpec, use JS_FS, JS_FN, JS_SYM_FN, JS_FNINFO, JS_SELF_HOSTED_FN, JS_SELF_HOSTED_SYM_FN, JS_SYM_FNSPEC, JS_FNSPEC, and JS_FS_END.

See Also

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

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

发布评论

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

词条统计

浏览:96 次

字数:7032

最后编辑:7年前

编辑次数:0 次

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