JS_FS 编辑
Macros for describing functions, for use with JS_DefineProperties
and JS_InitClass
.
Syntax
#define JS_FS(name,call,nargs,flags) ... #define JS_FN(name,call,nargs,flags) ... #define JS_SYM_FN(symbol,call,nargs,flags) ... // Added in SpiderMonkey 38 #define JS_FNINFO(name,call,info,nargs,flags) ... // Added in SpiderMonkey 17 #define JS_SELF_HOSTED_FN(name,selfHostedName,nargs,flags) ... // Added in SpiderMonkey 31 #define JS_SELF_HOSTED_SYM_FN(symbol, selfHostedName, nargs, flags) ... // Added in SpiderMonkey 38 #define JS_SYM_FNSPEC(symbol, call, info, nargs, flags, selfHostedName) ... // Added in SpiderMonkey 38 #define JS_FNSPEC(name,call,info,nargs,flags,selfHostedName) ... // Added in SpiderMonkey 31 #define JS_FS_END ...
Name | Type | Description |
---|---|---|
name | const char * | The JavaScript name for the function. (or index, if JSPROP_INDEX is present in flags) |
symbol | a member name of JS::SymbolCode | The JavaScript symbol for the function. |
call | JSNative | Pointer to the C/C++ implementation of the function. |
info | const JSJitInfo * | Pointer to the Jit Info. |
nargs | uint16_t | The number of arguments the function expects. |
flags | uint16 | The bitwise OR of any number of function flags. |
selfHostedName | const char * | The function's name in Self-Hosted JavaScript code. |
Description
Use these macros to define an array of JSFunctionSpec
s to pass to JS_DefineFunctions
or JS_InitClass
.
JS_FN
(whose name pays homage to the old JSNative
/JSFastNative
split) simply adds the flag JSFUN_STUB_GSOPS
. JS_FNINFO
allows the simple adding of JSJitInfos
. JS_SELF_HOSTED_FN
declares a self-hosted function. Finally JS_FNSPEC
has slots for all the fields.
The _SYM
variants allow defining a function with a symbol key rather than a string key. For example, use JS_SYM_FN(iterator, ...)
to define an @@iterator
method. (In builds without ES6 symbols, it defines a method with the string id "@@iterator"
.)
See an example in the JSAPI User Guide.
See Also
- MXR ID Search for
JS_FS
- MXR ID Search for
JS_FN
- MXR ID Search for
JS_SYM_FN
- MXR ID Search for
JS_FNINFO
- MXR ID Search for
JS_SELF_HOSTED_FN
- MXR ID Search for
JS_SELF_HOSTED_SYM_FN
- MXR ID Search for
JS_SYM_FNSPEC
- MXR ID Search for
JS_FNSPEC
- MXR ID Search for
JS_FS_END
JSFunctionSpec
JS_DefineProperties
JS_InitClass
- bug 775788 - added
JS_FNINFO
. - bug 920433 - added
JS_SELF_HOSTED_FN
andJS_FNSPEC
. - bug 1082672 - added
JS_SYM_FN
JS_SELF_HOSTED_SYM_FN
JS_SYM_FNSPEC
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论