mozilla
Your Search Results

    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 JSFunctionSpecs 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

    Document Tags and Contributors

    Contributors to this page: hdon, fscholz, tschneidereit, Jorend, arai
    Last updated by: arai,
    Hide Sidebar