Entry: 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;
};
Argument Type Description
*name const char Name to assign to the function.
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 uint8 Number of arguments to pass to this function.
flags uint8 Function 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.
extra uint16 Reserved 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:
|
|
|