JavaScript-1.5 Reference

JSFunctionSpec Data Structure

Summary

Defines a single function for an object.

Syntax

struct JSFunctionSpec {
    const char *name;
    JSNative call;
    uint8 nargs;
    uint8 flags;
    uint16 extra;
};
NameTypeDescription
*nameconst charName to assign to the function.
callJSNativeThe built-in JS call wrapped by this function. If the function does not wrap a native JS call, set this value to NULL.
nargsuint8Number of arguments to pass to this function.
flagsuint8Function attributes. If set to 0 the function has no attributes. Otherwise, existing applications can set flags to either or both of the following attributes OR'd:
JSFUN_BOUND_METHOD
JSFUN_GLOBAL_PARENT
Note that these attributes are deprecated, and continue to be supported only for backward compatibility with existing applications. New applications should not use these attributes.
extrauint16Reserved for future use.

Description

JSFuctionSpec defines the attributes for a single JS function to associate with an object. Generally, you populate an array of JSFunctionSpec to define all the functions for an object, and then call JS_DefineFunctions 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.

See Also

Groups [ Data Structure ]
Documents [ LXR ID Search ]
Entries [ JSFUN_BOUND_METHOD | JSFUN_GLOBAL_PARENT | JSPROP_INDEX | JS_CallFunction | JS_CallFunctionName | JS_CallFunctionValue | JS_CompileFunction | JS_DecompileFunction | JS_DecompileFunctionBody | JS_DefineFunction | JS_DefineFunctions | JS_GetFunctionName | JS_GetFunctionObject | JS_NewFunction | JS_SetBranchCallback ]

This page was generated by APIDOC