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;
Name | Type | Description |
---|---|---|
name | const char * | The function's name. |
call | JSNativeWrapper | The built-in JS call wrapped by this function. If the function does not wrap a native JS call, set this value to NULL . |
nargs | uint16_t | The value used for Function.length . This no longer guarantees anything about the vp array. |
flags | uint16_t | The bitwise OR of any number of function flags. |
selfHostedName | const 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论