mozilla
Your Search Results

    JSFunctionSpec

    Defines a single function for an object.

    Syntax

    struct JSFunctionSpec {
        const char *name;
        JSNative call;
        uint16 nargs;
        uint16 flags;
        uint32 extra; JSAPI 1.8 and earlier
    };
    Name Type Description
    name const char * The function's name.
    call JSNative 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 The value used for Function.length. This no longer guarantees anything about the vp array.
    flags uint16 The bitwise OR of any number of property attributes and function flags, and optionally JSFUN_STUB_GSOPS.
    extra uint32 JSAPI 1.8 and earlier The lower 16 bits indicate the number of extra local roots the function desires, available at argv[MAX(nargs, argc)] onward. The upper 16 bits must be zero and are currently reserved. In older versions of SpiderMonkey, this field was a uint16 required to be 0.

    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.

    MXR ID Search for JSFunctionSpec

    Document Tags and Contributors

    Contributors to this page: Jorend
    Last updated by: Jorend,